如何禁用android中的默认后退按钮
可能的重复:
禁用 android 中的后退按钮
在我的应用程序中从一个活动切换到另一个活动,就像 A- >B->C 或 C->A 我放置了按钮,因为应用程序的操作是这样的。所以不需要android默认的后退按钮。如果用户错误点击,则不应执行任何操作。为此,如何禁用后退按钮。
Possible Duplicate:
Disable back button in android
in my app to from one activity to other just like A->B->C or C->A i have placed buttons because the operations of the app are like that. So there is no need for the default back button of android. If the user wrongly clicks there should not be any operation done. For this how to disable the back button.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您不想返回特定的 Activity,另一种方法是在 Activity B 的
startActivity()
之后调用 finish()。代码片段:
If you don't want to return to a specific Activity, another approach would be to call finish() after
startActivity()
from Activity B.Code snippet:
我认为您不应该为用户禁用后退按钮。他们可能会生气/不安。我至少会是这样。
最好使用 FLAG_ACTIVITY_NO_HISTORY 或 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS 启动活动。
I don't think that you should disable the back button for users. They would probably get angry/upset. I would at least be that.
It's better to either start the activity with FLAG_ACTIVITY_NO_HISTORY or FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS.