I have a Checkbox
in a ListView
to select items and I have one Button
outside the ListView
. Initially the Checkbox
should be hidden, when I click that Button
the Checkbox
should display in the ListView
and vice versa.
I have one issue in that, when I press the Button
initially it displays one Checkbox
and again I press the Button
it show a few checkboxes but what I want was initially it should be invisible when I press the Button
it should be visible in ListView
Note: I have a Button
in class and Checkbox
in adapter
sdel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((datalist) mlistView.getAdapter()). toggleChecks();
((datalist)mlistView.getAdapter()).notifyDataSetChanged();
}
});
public void toggleChecks() {
for (int i = 0;i<sms.size();i++) {
holder.cb.setVisibility(CheckBox.VISIBLE);
}
isCheckBoxVisible=!isCheckBoxVisible;
notifyDataSetChanged();
}