我有一个简单的 ProgressDialog,但我意识到如果我按下搜索按钮,对话框将被关闭。在此过程中如何禁用搜索按钮按下?
dialog = new ProgressDialog(Main.this);
dialog.setTitle("Working in progress");
dialog.setMessage("Please wait...");
dialog.setCancelable(false);
dialog.show();
我放了这个,它没有用。
dialog = new ProgressDialog(Main.this){
@Override
public boolean onSearchRequested() {
return false;
}
};
这也行不通。
dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
return true; // Pretend we processed it
}
return false; // Any other keys are still processed as normal
}
});