Question

How to enable all the items in listview when check box is selected and disabled when check box is unchecked.I have used

if(checkbox.isChecked)
{
listview.setEnabled(false)
listview.setClickable(false)
}
else
{
listview.setEnabled(true)
listview.setClickable(true)
}

But it is not working.Any help would be greatly appreciated.

Thanks in Advance:)

Was it helpful?

Solution

 if(yourcheckbox.isChecked()){
     yourlistview.setClickable(true);} 
 else{
      yourlistview.setClickable(false);} 

You can run this as a background process, in a separate thread so it keeps getting checked, whether the checkbox is checked or not.

OTHER TIPS

you can use OncheckedChangeListener method of Checkbox class

checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton arg0, boolean isChecked) {
                if(isChecked)
                {
                    listview.setEnabled(false)
                    listview.setClickable(false)
                }
                else
                {
                    listview.setEnabled(true)
                    listview.setClickable(true)
                }

            }
        });

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top