【Android】AlertDialog禁止返回键
1、一般的实现弹出框的代码AlertDialog.Builder localBuilder = new AlertDialog.Builder(activity);localBuilder.setMessage(msg);localBuilder.setTitle("提示");localBuilder.setPositiveButton("确认",new DialogInterface.OnClickListener() { public void onClick( DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) { paramAnonymousDialogInterface.dismiss(); }});localBuilder.setNegativeButton("取消",new DialogInterface.OnClickListener() { public void onClick( DialogInterface paramAnonymousDialogInterface,int paramAnonymousInt) { paramAnonymousDialogInterface.dismiss(); }});localBuilder.setCancelable(false);localBuilder.create().show();

3、//由于设置alertDialog.setCancelable(false);但是按了KeyEvent.KE鳔柩寞泷YCODE_SEARCH,对话框还是会Dismiss掉。设置setOnKeyListener屏蔽KeyEvent.KEYCODE_SEARCH的触法处理。

5、alertDialog.setCancelable(false);然后设置setOnKeyListener()(自己重写按钮触法监听)
