标签:
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(); } });
标签:
原文地址:http://www.cnblogs.com/84126858jmz/p/4891031.html