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