Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is mostly likely that your getView() method correctly initialises a new cell view but never updates the state of a cell view that has been recycled. So essentially each cell view will only ever display the state it was initialised to. It should look something like this:</p> <pre><code>public View getView(int position, View convertView, ViewGroup parent) { View cell = convertView; if (cell == null) { // No View passed, create one. cell = mInflater.inflate(R.layout.galleryitem, null); // Setup the View content ImageView imageView = (ImageView)cell.findViewById(R.id.thumbImage); CheckBox checkBox = (CheckBox) cell.findViewById(R.id.itemCheckBox); checkBox.setChecked(checkboxesState[position]); checkBox.setId(position); imageView.setImageBitmap(downsample(mThumbIds[position])); // Setup the View behavior imageView.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Uncheck all checked items uncheckAll(); } }); checkBox.setOnClickListener(new OnClickListener() { public void onClick(View v) { CheckBox cb = (CheckBox) v; checkboxesState[cb.getId()] = cb.isChecked(); } }); } else { ImageView imageView = (ImageView)cell.findViewById(R.id.thumbImage); CheckBox checkBox = (CheckBox) cell.findViewById(R.id.itemCheckBox); checkBox.setChecked(checkboxesState[position]); checkBox.setId(position); imageView.setImageBitmap(downsample(mThumbIds[position])); } return cell; } </code></pre> <p>Additionally to improve the performance of your getView() method take a look at this <a href="http://developer.android.com/training/improving-layouts/smooth-scrolling.html#ViewHolder" rel="nofollow">tutorial</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload