ProgressDialog水平进度条
findViewById(R.id.btn).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final ProgressDialog pro = new ProgressDialog(MainActivity.this); pro.setTitle("搜索网络"); pro.setMessage("请耐心等待"); //设置最大值 pro.setMax(max_pro); //设置初始值 pro.setProgress(50); //设置样式 pro.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); pro.setButton("后台处理",new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { pro.dismiss(); } }); //启动进度条 pro.onStart(); new Thread(){ public void run() { for (int i = 0; i < max_pro; i++) { try { Thread.sleep(100); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } //设置每次增加的度 pro.incrementProgressBy(i); } pro.dismiss(); }; }.start(); pro.show(); } });