import android.widget.Button;
import android.widget.Toast;
public class SecondActivity extends Activity implements Runnable{
/**
* Called when the activity is first created.
* Activity入口
* */
private Button b_dialog,b_dialog1,button;//两个按钮
private ProgressDialog pd,pd1;//进度条对话框
private int count;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second);//关联对应的界面
b_dialog = (Button)this.findViewById(R.id.button_dialog);
b_dialog1 = (Button)this.findViewById(R.id.Button_dialog1);
//处理事件发生时要做的事
b_dialog.setOnClickListener(listener);
b_dialog1.setOnClickListener(listener);
</span>
<span style=""> }
//定义监听器对象
private OnClickListener listener = new OnClickListener() {
// 鼠标按下后
public void onClick(View v) {
// 得到当前被触发的事件的ID —— 类型是int
int id = v.getId();
if(id == R.id.button_dialog){
//按下确定键就会消失的进程对话框
// pd = new ProgressDialog(SecondActivity.this);// 创建ProgressDialog对象
// pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);// 设置进度条风格,风格为圆形,旋转的
// pd.setTitle("提示");// 设置ProgressDialog 标题
// pd.setMessage("这是一个圆形进度条对话框");// 设置ProgressDialog提示信息
// pd.setIcon(R.drawable.icon);// 设置ProgressDialog标题图标
// // 设置ProgressDialog 的进度条是否不明确 false 就是不设置为不明确
// pd.setIndeterminate(false);
// pd.setCancelable(true); // 设置ProgressDialog 是否可以按退回键取消
// pd.setButton("确定", new Bt1DialogListener()); // 设置ProgressDialog 的一个Button
// pd.show(); // 让ProgressDialog显示
//过1秒钟就会自己消失的进程对话框
//弹出另外一种对话框
pd = ProgressDialog.show(SecondActivity.this, "自动关闭对话框", "Working,,,,,,1秒", true, false);
Thread thread = new Thread(SecondActivity.this);//开启一个线程来延时
thread.start();//启动线程
}else if(id == R.id.Button_dialog1){
pd1 = new ProgressDialog(SecondActivity.this);// 创建ProgressDialog对象
pd1.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);// 设置进度条风格,风格为圆形,旋转的
pd1.setTitle("提示");// 设置ProgressDialog 标题
pd1.setMessage("这是一个条状进度条对话框");// 设置ProgressDialog提示信息










