The game has 4 character action lists. When you click on each item of each list, the action is performed. To repeat the action once again, you need to wait (the waiting time is different everywhere, let's call it timeout); When you click on an item in the background, a horizontal progress bar starts to act. When the progress bar reaches the end, the action can be repeated. The time of progression depends on the timeout.
In general, I hang the listener on the list ...
lv_inspiration.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView<?> p1, View p2, int p3, long p4) { b = (ProgressBar)p2.findViewById(R.id.progress_bar_item); cdt = new CountDownTimer(100000,1000) { @Override public void onTick(long millisUntilFinished) { i++; b.setProgress(i); } @Override public void onFinish() { i=0; } }; cdt.start(); } });
And I get such a picture - when you click on the item, the progress bar starts and starts working. If I wait for him to finish and click on the second, then nothing happens. If you press the second one while the first one is running, the first one stops, the second one continues the progress from the point where the first one stops and with double speed. In addition, when scrolling fly progress. What's wrong? Help, maybe there is some article? Or maybe someone has seen such an implementation somewhere?
UPD Changed the code of the getView()
method in your SimpleAdapter
, now other items will work when the progress bar reaches the end. But, if you click on the item and scroll through the list so that the clicked item is not visible, the progress bar continues to work in other items, that is, it "jumps". And if, without waiting for the end of the first to click on the second, then the first one stops, the second continues to progress with double speed. Well, and so on with this effect. Help, what's wrong? And what the hell is with this ListView?