lundi 19 juin 2017

Checkbox becoming 'sticky' in RecyclerView for Dialog in Android

I have a dialog which takes in user input through a list with checkboxes, whose layout is a RecyclerView. But when i select a checkbox in the list, another checkbox further down in the list also gets checked, but which i didn't do. These images will help illustrate my point.

Here, i've only selected Calendar and Camera:

enter image description here

but further down in the list, Google and Maps also get selected which i didn't select.

enter image description here

My code for bindActivity is:

public void bindActivity(ResolveInfo resolveInfo)
        {
            mResolveInfo = resolveInfo;
            PackageManager pm = getActivity().getPackageManager();
            String appName = mResolveInfo.loadLabel(pm).toString();
            mAppImageView.setImageDrawable(resolveInfo.loadIcon(pm));
            mAppTextView.setText(appName);
        }

If i add mAppCheckBox.setChecked(false) in bindActivity, then when i go further down in the list and the RecyclerView 'recycles' the list, and then i go up, my earlier selection becomes unselected.

I would love any suggestions on how to get rid of the 'sticky' checkbox.




Aucun commentaire:

Enregistrer un commentaire