De *_*nne 4 android dialog onclick android-asynctask
我开始AsyncTask加载一个需要一些时间的文件.要通知用户我正在显示ProgressDialog,但是如果我触摸屏幕则会ProgressDialog立即关闭.可能是什么原因造成的?
public LoadTask(Activity activity, FaceRecognizer recognizer,SecretKey key) {
this.key = key;
this.recognizer = recognizer;
dialog = new ProgressDialog(activity);
}
@Override
protected void onPreExecute() {
dialog.setMessage("Loading the recognizer...");
dialog.show();
}
@Override
protected Boolean doInBackground(Void... params) {
recognizer.load(key);
return null;
}
@Override
protected void onPostExecute(Boolean result) {
if (dialog.isShowing()) {
dialog.dismiss();
}
Run Code Online (Sandbox Code Playgroud)
用这个...
public LoadTask(Activity activity, FaceRecognizer recognizer,SecretKey key) {
this.key = key;
this.recognizer = recognizer;
dialog = new ProgressDialog(activity);
///////////////////////////////////////////
dialog.setCancelable(false);
//or////////
dialog.setCanceledOnTouchOutside(false);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
665 次 |
| 最近记录: |