熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

ProgressDialog實現

2022-06-13   來源: Java核心技術 
    下面我們就以ProgressDialog實現來寫如下代碼
[java]
    package comexampleprogressbar;
    import javaioIOException;
    import androidosBundle;
    import androidappActivity;
    import androidappProgressDialog;
    import androidviewMenu;
    import androidviewView;
    import androidwidgetButton;
    public class MainActivity extends Activity {
    private Button btn;
    private ProgressDialog pg;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
    superonCreate(savedInstanceState)
    setContentView(Rlayoutmain)
    btn=(Button)findViewById(Ridb
    btnsetOnClickListener(new ButtonOnClickListener()
    {
    public void onClick(View view)
    {
    final CharSequence Body=Please wait for a moment;
    final CharSequence Title=Progress Bar;
    pg=ProgressDialogshow(MainActivitythis Title Body)
    new Thread()
    {
    public void run()
    {
    try
    {
    sleep(
    }
    catch(Exception e)
    {
    eprintStackTrace()
    }
    finally
    {
    pgdismiss()
    }
    }
    }start()
    }
    })
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present
    getMenuInflater()inflate(numain menu)
    return true;
    }
    }


From:http://tw.wingwit.com/Article/program/Java/hx/201311/26108.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.