tôi có một ProgressDialog thực hiện như thế này:Tại sao ProgressDialog của tôi nghe trên BẤT K KEY KEY (chạm) thay vì backbutton để loại bỏ?
// show progress dialog while date is loading
progressDialog = ProgressDialog.show(XYActivity.this, getResources().getString(R.string.progress_dialog_please_wait), getResources().getString(R.string.progress_dialog_loading), true);
progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
cancel(true);
Log.w(LOGTAG, "loading cancelled via back button");
}
});
progressDialog.setCancelable(true);
ProgressDialog này được thực hiện bên trong một AsyncTask (PreExecute), do đó hủy bỏ phương pháp (true) dừng AsyncTask. Điều này tất cả hoạt động tốt.
Các vấn đề là, mà tôi có thể hủy các ProgressDialog với bất kỳ cảm ứng ngẫu nhiên trên màn hình của tôi. Tôi muốn loại bỏ hộp thoại chỉ bằng cách nhấn nút backbutton. Làm ơn giúp tôi! Cảm ơn các bạn.
cảm ơn, sau khi thêm 'cancelDialog.setCancelable (false);' vào mã của bạn làm việc cho tôi, nhưng tôi đã tìm thấy giải pháp dễ dàng hơn, hãy xem bên dưới – GedankenNebel
Tôi tìm thấy giải pháp với 'progressDialog.setCanceledOnTouchOutside (false);':))) – GedankenNebel
ok ..! Bất kỳ cách nào mà vấn đề của bạn đã được giải quyết ...! cảm ơn..! – Dinesh