在需要自行耗时操作的时候,且希望操作时不被中断,可以加个小进度
1 public class MainActivity extends Activity { 2 3 4 5 private ProgressDialog progressDialog; 6 7 // ............ 8 9 /** 10 * 显示进度对话框 11 */ 12 private void showProgressDialog() { 13 if (progressDialog == null) { 14 progressDialog = new ProgressDialog(this); 15 progressDialog.setMessage("正在加载..."); 16 progressDialog.setCanceledOnTouchOutside(false); 17 } 18 progressDialog.show(); 19 } 20 21 /** 22 * 关闭进度对话框 23 */ 24 private void closeProgressDialog() { 25 if (progressDialog != null) { 26 progressDialog.dismiss(); 27 } 28 } 29 30 31 }
时间: 2024-11-08 16:36:14