I have a custom ListView
where clicking an item fires a new Activity
.
Each row of the ListView
has a CheckBox
and a TextView
.
This is the getView
method from my custom ListView
:
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.puzzles_row, null);
}
ListedPuzzle lp = items.get(position);
if (lp != null) {
TextView title = (TextView) v.findViewById(R.id.listTitles);
title.setText(lp.getTitle());
CheckBox star = (CheckBox) v.findViewById(R.id.star_listed);
star.setChecked(lp.isStarred());
star.setTag(new Integer(position));
star.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
Integer realPosition = (Integer) buttonView.getTag();
ListedPuzzle obj = items.get(realPosition);
starListedPuzzle(obj.getId(), isChecked);
}
});
}
return v;
}
The onCheckedChanged
is called when coming back from the another Activty, without possible user interaction to actually check anything.
The point is that used to work fine and haven't really change anything. I've read that it's a bug but can't really believe it.
It always calls the method on the same two items of the ListView
. Could they be set to checkedChange=true
somehow?