[英]Android back button act like hardware back button
I have an Activitiy
with a ListView
and some items. 我有一个带有
ListView
和一些项目的Activitiy
。 When I click on one item I get to the next Activity
. 当我单击一个项目时,我进入下一个
Activity
。
On the new Activity
when I click the hardware back button I get back to the Activity
with the ListView
and all the data is still there. 当我单击硬件后退按钮时,在新的
Activity
,我将使用ListView
返回到Activity
,并且所有数据仍然存在。
Using the back button (as defined in AndroidManifest.xml
) in the upper left corner all the data is gone. 使用左上角的后退按钮(在
AndroidManifest.xml
中定义),所有数据都消失了。
How can I make this software back button act like the hardware back button? 如何使该软件后退按钮像硬件后退按钮一样工作?
您需要在没有listview
的activity
中覆盖onBackPressed()
方法,并在其中检查是否要像超级角色一样(转到上一个活动不做任何事情)或做某事(清除数据),然后调用超级
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.