Hello everyone :) In my practice for the first time there was such a problem. I'm doing a simple simulator.

There is a ListView, I fill it through SimpleAdapter, in the foreground of the item is an action text (for example, eat a sausage). In the background is a full item progressbar that serves as a background. From the very beginning, all the progress bars stand with the progress 100. When the player clicks on "eat sausage" the progress bar is reset to 0 and begins to slowly grow to the end. When he grows, the player can not press again, he waits. And when the progress bar reaches the end, filling in the entire background item, the action can be repeated . There are a lot of such actions. Ie, the player can click on several items and they should go to the end, without fail.

Everything would be good, if not everyone knows the "feature" of these lists in android - if you launch the progress bar and move it behind the screen, then when you return, the progress itself is put on 100. Need to add my adapter, but I don’t know how ?

I have some idea how this should work:

1) Create an array of int values, which will be progress

2) In the list listener, change the value in this array at the position of the clicked item to 0

3) Next, in the listener, run CountDownTimer , which in the onTick method will change the value in the progress array each time

4) And the adapter. In the getView method getView assign progress from an array, just by position

How to implement it? With me: when scrolling, the progress is reset to 100

I can not do anything, help: (

  • Here the problem is apparently in data caching. I had a similar problem when trying to display different views in lists. Go to RecyclerView. There are more options available ... - plesser

1 answer 1

Try clicking on the list item to set for it (for the view of the item)

 setHasTransientState(true); 

When filling progress accordingly set to false.

  • You are welcome. If you know English, then here is more youtube.com/… - Fitz