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.
我正在为android平台实现一个游戏。游戏快准备好了,但我遇到了一个奇怪的问题:
当玩家完成游戏时,会显示“恭喜你赢了”页面。该视图中的按钮正在重定向到主页。当玩家单击返回按钮时会出现问题,因为游戏会再次显示。
有没有办法控制应该出现的后退按钮行为?喜欢总是重定向到主页
先感谢您
这就是你要找的。
Intent a = new Intent(DisplayPage.this,MainPage.class); a.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(a);
这肯定会帮助你。
我找到了一个更好的解决方案:
@Override public void onBackPressed() { }
只需在没有实现的情况下覆盖该功能,然后,后退按钮功能将根据需要消失。