Representations are processed in ListView. This is why some are checked when you think this should not be.
Here's the deal: the checkbox has no idea which element in your adapter it represents. This is only a checkbox in a row in a ListView. You need to do something to βteachβ the rows that are currently being displayed in your dataset. Therefore, instead of using something as simple as a String array as data for your adapter, create a new model object that stores the state of the flag. Then, before you return the string to getView()
, you can do something like:
//somewhere in your class private RowData getData(int position) { return(((MyAdapter)getListAdapter()).getItem(position)); } //..then in your adapter in getView() RowData object = getModel(position); if(object.isChecked()) { myCheckbox.setChecked(true); } else { myCheckbox.setChecked(false); } //then retun your view.
LuxuryMode
source share