开发者

List adapters as activity class members

I find it convenient to store list adapters as class members in my activities. The reason for this is that I can call the "invalidate" methods on it when i update my data, and the list will refresh.

How will this approach work when the activity state 开发者_如何学运维is serialized/moved out of memory and back in, will I need to reconstruct the adapter in onRestoreInstanceState to make my app behave well?

I can of course keep the data as class members and re construct the adapter from the data on activity state serialization/deserialization.

I can also keep my Listview as a class member and use getAdapter().notify... when I change the data.

Can anyone point me in the direction of "best practice" regarding this issue?


I believe they will be restored. I've used the same thing in many projects and I've had no problem. You should take care though if you do the same thing to UI objects so that you don't end up with leaked memory.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜