I faced with a weird problem. I have an android application and it contains activity that includes ListViewAdapter. Each element contains a checkbox. And i have the following code:
public View getView(final int position, View convertView, ViewGroup parent) {
CheckBox checkbox = (CheckBox)v.findViewById(R.id.checkbox);
checkbox.setChecked(checked[position]);
checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener(){
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// some code
}
});
}
And when i scroll my listview down my OnCheckedChangeListener fires and reset my checkbox if it was set. Why does it happend? I excpeted OnCheckedChangeListener will be triggered when i click checkbox manually or call setChecked programmatically but it does when i scroll down too. Why?
Aucun commentaire:
Enregistrer un commentaire