0
A
回答
0
嘗試這個
public void onBackPressed() {
showExitAlertBox();
}
public void showExitAlertBox() {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
alertDialog.setMessage("You want to quit the play?");
//Yes Quit then go to category page
alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int button) {
Intent intent = new Intent(getApplicationContext(), PREVIOUSACTIVITY.class);
startActivity(intent);
finish();
}
});
//no Quit stay on same page
alertDialog.setNegativeButton("NO", null);
alertDialog.show();
}
相關問題
- 1. 如何使用返回按鈕返回上一個活動?
- 2. Android活動返回按鈕返回上一個活動,但沒有數據
- 3. 活動和返回按鈕
- 4. 返回上一個活動
- 5. 返回上一個活動
- 6. 返回上一個活動
- 7. 如何在返回按下時返回上一個活動?
- 8. 手動返回上一個活動
- 9. 使用BaseAdapter返回上一個活動的按鈕
- 10. Xamarin的Android:動作條搜索查看返回的ActionView空
- 11. Android返回上一活動
- 12. 如何通過操作欄返回到上一個活動?
- 13. 返回上一個活動阻止回來的初始活動
- 14. 按鈕返回=動作按鈕主頁
- 15. 讓搜索活動返回結果?
- 16. Android後退按鈕不返回到上一個活動
- 17. 如何通過點擊按鈕返回上一個活動?
- 18. 使用DrawerLayout後退按鈕返回到上一個活動
- 19. 返回按鈕不返回到先前的活動
- 20. 當按下返回按鈕,發送一個值前一活動
- 21. 當返回按鈕被點擊活動
- 22. 按鈕返回到其他活動
- 23. 返回按鈕完成父級活動
- 24. Android如何在活動中添加返回按鈕以返回片段活動
- 25. 當返回按鈕關閉活動時返回意圖結果
- 26. 如何返回上一個活動?
- 27. EmailIntent返回上一個活動
- 28. 返回上一個活動(PreferenceManager)
- 29. 返回到上一個活動
- 30. 如何返回上一個活動?
不是我想要的,但這個工作了:http://stackoverflow.com/questions/37039511/how-to-detect-searchviews-back-button-press –
你在找什麼?如果它工作,然後單擊正確的標記 –