开发者

Reset Activity when phones back button is clicked

Is it possible to reset a activity to its normal state when a user clicks the back button from the previous page.

Use Case: On my main activity I have checkboxes and the user goes to the next activity using intent. That activity has a "Back to Main Page" button, but when the user just clicks the back button on the 开发者_如何学Pythonphone the checkboxes are already checked from the last time the user was on the page.


If you want to reset only when returning from that activity then use startActivityForResult() and override onActivityResult.

If you want to reset everytime then reset in onResume()


Move the code that sets the default state of the checkboxes from the onCreate() to onResume() method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜