是否有可能重写onBack pressed()只有一个活动?
Is it possible to override onBackPressed() for only one activity ?
在后退按钮点击我要调用具体活动的对话,但在所有其他活动,我希望像以前(去previous活动)工作它的工作。 。
On back button click I want to call a dialog on a specific Activity, but in all other activities i want it to work as it worked before (going to previous activities) . . .
感谢事先你anwsers。
Thanks For your anwsers in advance.
EDITED
感谢大家对你的anwsers,我已经一切都像你告诉我,但我的问题是,当我点击后退按钮上的其他活动,我要我的previous活动(唯一在那里我有后退按钮重写),我认为这是不工作,我认为这是压倒一切的onBack pressed()在整个应用程序,现在我明白了:D
Thank you everyone for your anwsers, I already had everything like you told me, but my problem was that when i was clicking back button on another Activity, I was going to my previous Activity (The one where i had back button Overriden) and i thought that it wasn't working, i thought it was overriding onBackPressed() in whole Application, now i got it :D
是的。只有覆盖它在一个活动
与
Yes. Only override it in that one Activity
with
@Override
public void onBackPressed()
{
// code here to show dialog
super.onBackPressed(); // optional depending on your needs
}
不要把这个code在任何其他活动