Android store listview views into ArrayList
I have the problem of the ListView re-rendering and changing the values within my list view views. Each cell has interactive elements with numerical values that are set, unfortunately once off screen these numbers are re-rendered seemingly at random!
I've since discovered that Listview needs to hav开发者_JS百科e an extended view class that allows the values at that position to be stored.
I need to pass several values, so far all the examples I have seen only show one method with one values per cell (referring to http://commonsware.com/Android/excerpt.pdf), I am seeking assistance on how to store the values for my application.
I have a "total" count , and a separate count that I can increase and decrease the value of, via buttons within the listview cell. I need to store these individual totals and values within that position in the View. I supposed I would have a method/constructor that simply includes those values, but in this syntax is seems the super. will not allow this override.
Insight Appreciated. If this wasn't clear without code, sure just let me know. But if you are already familiar with this problem and the most generic way to tackle it, that would be great too.
Listview recycles its views, so if you don't store the values you are displaying explicitly using a custom adapter fit for your purposes, that is probably were it goes wrong. Whenever you scroll a view in the listview out of the screen, it throws away all the values in there, and pastes it on top with new data.
So what you probably need is a custom adapter storing the numbers you want to display; here is a good place to start off from in understanding it better: http://developer.android.com/videos/index.html#v=wDBM6wVEO70
精彩评论