How to enable back button of phone to go back to previous activity without enabling back button icon on action bar?

huangapple go评论74阅读模式
英文:

How to enable back button of phone to go back to previous activity without enabling back button icon on action bar?

问题

假设我从当前活动切换到另一个活动,然后需要通过手机上原本存在的返回按钮回到先前的活动,同时还有一个主页按钮和菜单按钮。我已经禁用了我的操作栏,并且不想启用它。我也不想在我的活动中创建一个代表返回的图标。

请帮忙!

英文:

Suppose I move to another activity from my current one and then I need to go back to previous activity by pressing the back button originally present in the phone along with a home button and menu button. I have disabled my Action Bar and I don't want to enable it. Nor I want to create an icon in my activity that represents back.

Please Help!

答案1

得分: 1

要启动返回操作,您可以从您的活动中调用以下代码:

super.onBackPressed();
英文:

to initiate the back operation you can call

super.onBackPressed();

from your activity.

huangapple
  • 本文由 发表于 2020年8月7日 23:48:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/63305173.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定