用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - android代码库

ProgressDialog 加载中,请稍候...

2012-09-05 作者: 神马举报

[android]代码库

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
 
public class EX03_18 extends Activity {
    private Button mButton1;
    private TextView mTextView1;
    public ProgressDialog myDialog = null;
 
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
 
        mButton1 = (Button) findViewById(R.id.myButton1);
        mTextView1 = (TextView) findViewById(R.id.myTextView1);
        mButton1.setOnClickListener(myShowProgressBar);
    }
 
    Button.OnClickListener myShowProgressBar = new Button.OnClickListener() {
        public void onClick(View arg0) {
            final CharSequence strDialogTitle = getString(R.string.str_dialog_title);
            final CharSequence strDialogBody = getString(R.string.str_dialog_body);
            // 显示Progress对话框
            myDialog = ProgressDialog.show(EX03_18.this, strDialogTitle,
                    strDialogBody, true);
            mTextView1.setText(strDialogBody);
            new Thread() {
                public void run() {
                    try {
                        /* 在这里写上要背景执行的程序片段 */
                        /* 为了明显看见效果,以暂停3秒作为示范 */
                        sleep(3000);
                    } catch (Exception e) {
                        e.printStackTrace();
                    } finally { // 卸除所建立的myDialog对象。
                        myDialog.dismiss();
                    }
                }
            }.start(); /* 开始执行线程 */
        }
        /* End: public void onClick(View arg0) */
    };
}

[代码运行效果截图]


ProgressDialog 加载中,请稍候...


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...