开发者

How to save the sate of my Activity

开发者 https://www.devze.com 2023-03-19 09:44 出处:网络
I have an EditText followed by a list view under it. So it works like this - when u type something in the edit text it shows items from the list which match the text above.

I have an EditText followed by a list view under it. So it works like this - when u type something in the edit text it shows items from the list which match the text above. Anyway I need to save the state of list view. means if 开发者_StackOverflow中文版the user navigates away from this screen and comes back the list view should have the same state and the edit text should be filled with the same text. Hope u got it.

Please tell me how to achieve this.


Save your data in onPause(), and restore it in onResume() if needed.


You should save your edit text input string on (over ride those methods)

protected void onPause()

And when user returns, you just bind your string to edit text view on

protected void onResume()

http://developer.android.com/guide/topics/fundamentals/activities.html#Lifecycle

0

精彩评论

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

关注公众号