I've got a ListView
, each of item
of which contains a ToggleButton
. After I toggle it and then scroll up or down, the ListView is recycling the Views and so some of the others are mirroring the checked state of the ToggleButton
. I don't want this. How can I prevent it?
One of the features of ListView , if I understood it right, is that it recycle views and just replaces it with new data when an item is off the screen.
What is custom listview? Custom listview works based on customAdapter. In this custom adapter we can pass custom object. We are passing subject data to listview as shown below − Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Add this two methods to your Adapter.
@Override public int getViewTypeCount() { return getCount(); } @Override public int getItemViewType(int position) { return position; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With