最后,我在对话框中添加了一个键侦听器,以侦听Back键。onBackPressed()虽然没有覆盖的优雅,但是它可以工作。这是代码:
dlgDetails = new alertDialog.Builder(this) .setonKeyListener(new DialogInterface.onKeyListener() { @Override public boolean onKey (DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) { dialog.cancel(); showDialog(DIALOG_MENU); return true; } return false; } }) //(Rest of the .stuff ...)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)