I have a custom ListView. It's populated by cursor adapter. It's every row includes one ImageView, two TextViews and one ToggleButton. These all loads fine. When I change state of group of ToggleButtons to true, then when I scroll fast listView not scrolling smoothly it hangs for a sec and scrolls. It happens when after group of unchecked buttons appears group of checked buttons and vice versa. Why list view hangs while scrolling?
Any help would be appreciated. My code looks like this:
public void bindView(View view, Context context, final Cursor cursor) {
final ViewHolder viewHolder = new ViewHolder(view);
(...)
if (viewHolder.toggle_artist != null) {
viewHolder.toggle_artist.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int favourite = isChecked ? 1 : 0;
ContentValues value = new ContentValues();
String where = AmdmContract.ArtistEntry.TABLE_NAME + "." +
AmdmContract.ArtistEntry._ID + " = " + tableId;
value.put(AmdmContract.ArtistEntry.COLUMN_FAVORITE, favourite);
mContext.getContentResolver()
.update(AmdmContract.ArtistEntry.CONTENT_URI,
value, where, null);
}
});
int favFromDB = cursor.getInt(COL_FAVOURITE);
viewHolder.toggle_artist.setChecked(favFromDB == 1);
}
}