Skip to content

Instantly share code, notes, and snippets.

@vuhung3990
Last active February 2, 2016 02:19
Show Gist options
  • Save vuhung3990/26e947dd963e3727efa5 to your computer and use it in GitHub Desktop.
Save vuhung3990/26e947dd963e3727efa5 to your computer and use it in GitHub Desktop.
solved issui checkbox state in listview scroll
// Contructor ()
// StaticVar.java contain 'Expand_State' var
private List<ItemObject> list;
private int current_size;
StaticVar.Expand_State = new boolean[list.size()];
current_size = list.size();
// end Contructor--------------------------------
// @override Getview()
if(current_size != list.size()){
current_size = list.size();
boolean[] clone_state = StaticVar.Expand_State.clone();
StaticVar.Expand_State = new boolean[list.size()];
for(int i=0;i<clone_state.length;i++){
// if not out of bound Expand_State && clone_state[i] = true
if(i < StaticVar.Expand_State.length && clone_state[i]){
StaticVar.Expand_State[i] = clone_state[i]; // = true
}
}
}
// .........some coe here..........//
CheckBox checkbox = (CheckBox)convertView.findViewById(R.id.expand_btn);
checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
StaticVar.Expand_State[position] = isChecked;
}
});
checkbox.setChecked(StaticVar.Expand_State[position]);
// end Getview()----------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment