5
A
回答
0
这真的很棘手,我有LayoutInflater记住,但这件事情也需要关闭。一个俗气的方式做到这一点有一个视图,你只是做可见或不可见
0
我也遇到同样的问题,同时显示EULA对话框。 它由setOnKeyListener解决。
这里是解决方案:
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
.setTitle(title)
.setMessage(message)
.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(Constants.EULA_VERSION, versionInfo.versionCode);
editor.commit();
dialogInterface.dismiss();
}
})
.setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Close the activity once the EULA is declined.
mActivity.finish();
}
});
//To avoid skipping EULA screen through search & menu button.
builder.setOnKeyListener(new DialogInterface.OnKeyListener() {
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (keyCode < KeyEvent.KEYCODE_DPAD_UP || keyCode > KeyEvent.KEYCODE_DPAD_CENTER)
{
return true;
}
else
return false;
}
});
builder.create().show();
相关问题
- 1. 关闭没有按钮的AlertDialog
- 2. 单击按钮后请勿关闭AlertDialog
- 3. 如何关闭AlertDialog?
- 4. Android - 如何实现alertDialog动画关闭到活动按钮
- 5. 如何防止AlertDialog关闭?
- 6. 如何关闭Android alertdialog
- 7. 如何手动关闭alertDialog?
- 8. 如何自动关闭alertdialog
- 9. 在SherlockActivity中按下搜索按钮时关闭软键盘
- 10. 在不按下按钮的情况下关闭AlertDialog
- 11. 当按下中立按钮时阻止Android AlertDialog关闭
- 12. AlertDialog过得去硬件搜索按钮按下
- 13. 关闭AlertDialog框
- 14. 如何继承AlertDialog按钮
- 15. 让手机关闭引导按钮关闭引导模式
- 16. 如何按下CTabView关闭按钮?
- 17. 搜索查看关闭按钮被隐藏
- 18. 点击jqgrid中的查找按钮关闭搜索弹出框
- 19. 单击搜索按钮时强制关闭
- 20. 在鼠标上隐藏搜索文本框关闭按钮
- 21. 关闭搜索栏
- 22. AlertDialog按钮总是关闭对话框一旦点击
- 23. 停止AlertDialog从关闭正按钮点击
- 24. AlertDialog与LinearLayout不应该关闭按钮单击
- 25. 在关闭AlertDialog后获取单选按钮状态
- 26. 不要关闭alertdialog通过点击一个按钮 - Android的
- 27. PyQt5:如何让一个按钮关闭该GUI点击
- 28. 如何让一个JQuery关闭一个按钮?
- 29. 如何让jQuery模式关闭按钮更大
- 30. AlertDialog自动关闭
我不知道,但我很乐意看到有人回答这个问题。使用keyEvent类不起作用,因为OnKeyUp/Down/Longpress在对话框打开时触摸搜索键时不会执行。我想知道是否有其他方法可以被覆盖。 – 2011-04-21 21:21:15
即使我有同样的问题....任何想法的人? – mvrck 2011-07-20 10:20:37
对KeyEvent和onSearchRequested()不做任何处理。你试过了吗? – 2011-07-20 11:42:45