Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当用户单击主要活动上的后退按钮时,我希望弹出一个对话框,询问用户他是否“想离开”。我能够创建对话框并实现它,但我不确定如何在按下后退按钮时打开对话框。有什么建议么?
哪个API?这是 API 5+ 中最简单的方法
@Override public void onBackPressed () { //super.onBackPressed(); dialog.show(); }