开发者

Android ListView clears when hard BACK key is pressed

开发者_开发知识库In my android app I have a Tabhost with a ListView as one of the tabs. By clicking on an item in the ListView (an address) I start an Intent to Google Maps for directions and the choice dialog pops up for google maps, web browser etc. Problem is if I press the hard back button then the launch dialog goes away but also the ListView is cleared. Any idea why?


The caller activity is being "paused" and when resumed onCreate is called to let you "resume". You can save persistent data by overriding onSaveInstanceState and passing the data through the bundle by setting extras. Then check for these extras in the bundle passed to onCreate and perform any necessary actions needed to functionally resume.

For complex objects, you can serialize them (implement Serializable if need be) and then store them as extras in the bundle during onSaveInstanceState.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜