package com.yanjun;
import android.R.style;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public
class MainActivity
extends Activity {
/** Called when the activity is first created. */
ProgressDialog progressDialog =
null;
@Override
public
void onCreate(Bundle icicle) {
//是按鈕最爲桌面佈局
super.onCreate(icicle);
Button button =
new Button(
this);
setContentView(button);
button.setText(R.string.hello);
button.setOnClickListener(myShowProgressDialog);
}
Button.OnClickListener myShowProgressDialog =
new Button.OnClickListener() {
public
void onClick(View v) {
// TODO Auto-generated method stub
CharSequence charSequence = getString(R.string.dialog_title);
CharSequence charSequence2 = getString(R.string.dialog_message);
progressDialog = ProgressDialog.show(MainActivity.
this,charSequence,charSequence2,
true);
new Thread(){
@Override
public
void run() {
try {
sleep(3000);
}
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{ progressDialog.cancel(); } } }.start(); } }; }