开发者

ListActivity/ListView content is "disappearing"

I'm having a problem with my ListView in a ListActivity with a Custom ArrayAdapter.

When the ListActivity becomes hidden (paused, whatever), the data that was present in the ArrayAdpater seems to go away. Rotation works fine, but I am only assigning the array in the ArrayAdapter in the onCreate(), nowhere else. The array is stored in a global static so the array itself should be fine. but the ListView seems to be pitching the array somewhere after the onCreate in the Activity Lifecycle.

I'm thinking the array should be re-assigned on one of the onResume(), onStart() or onRestart(), but I'm looking for a more concrete reason as this happe开发者_如何学JAVAns only rarely and never with my Cursor based Adapters.


Your problem is a little vague, but I'll present a few tips to consider.

Don't populate data inside the onCreate method. onCreate() should be used to define the view. Use the onResume() to load data so you can clean up and save memory effectively with the onPause().

Be sure your custom ArrayAdapter is appropriately handling getView as this can be a source of other problems.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜