I have a listview whose items contain a few TextViews, and 7 custom CheckBoxes. In my adapter class I have ArrayList that stores all the data for each element, including boolean array for each checkbox's state.
When I scroll the list down I use convertView to draw new element. For example, if the first item disappeared, its view will be used for drawing, let's say, 6'th item. I also use ViewHolder to store references to all the Views inside every visible ListView's item.
Now, every checkbox has its onCheckedChangedListener, inside of which its new state is written into boolean array of according element of ArrayList. Like, we changed state of the 4'th checkbox of the 2'nd element of the ListView, so we need to find 2'nd element in ArrayList and changed 4'th value in its boolean array.
Except for changing boolean in ArrayList, when I change checkbox's state I also start an animation, and it's really important to start it only when I physically click on checkbox. But remember how I use disappeared item to draw new one? Since I'm reusing convertView I need to change its checkbox's states according to boolean array of the element that I'm trying to draw. For example, I'm drawing 6'th element of the ListView and use view of the first element for it. Let's say, the first element had state of its checkboxes like this:
{true, true, true, true, true, false, false}
and 6'th element should be displayed like this:
{false, false, false, false, false, false, false}
For the first 5 of them onCheckedChanged() will be invoked, which will trigger the animation. But as I said, I want to start animation only if I physically clicked the checkbox. I was going to use another callback, onTouchEvent() would be great, but it doesn't have boolean parameter that shows if checkbox is checked or not. Any ideas will be strongly appreciated.
Aucun commentaire:
Enregistrer un commentaire