Android How to Save states of my listview
Is there a listviewObject.saveViewStates(view)
function I can use? I have listviews, I have other listviews 开发者_如何学Pythonwith custom adapters, but neither of these save states of the view. There is a lot of dynamically generated content in these listviews, so of course, when it that row goes outside of the view, the data is reset.
I understand the concept behind a viewholder, yet I am having great difficulty retroactively fitting my listviews with them. (nullexceptions, illegalstateexceptions)
Since the common way of holding the view is to pass the view, wouldn't it make sense that the listview had a built in function that simply accepted the view as a variable? I understand that the listview was created with limited memory in mind, it just seems negligent that there wouldn't be a way to save the states built in, in contrast to the webview - which is also built with limited memory in mind - the user can force enable/disable caching, do their own memory management etc.
Insight appreciated
The whole idea of the list is that it is dynamic and can be potentially long - so have lots of rows which are invisible. Therefore the aim of the adapter approach is to only keep as many views as visible on screen and fill them with data by running getView() - which should reuse views if no longer needed.
So when you take that in the account, it becomes pretty straightforward, that it's the data model behind (stored in adapter) that should get saved/reloaded and the list views should be rebuild when list is reloaded and filled with the data from the model.
This is more in-line with the list concept.
精彩评论