-2

I have a listView (android.R.layout.simple_list_item_multiple_choice) where each row of list have a checkbox.

I need to block all checkbox's when click in one button. But I don't know how i can block ALL checkbox's simultaneously.

if(checkAll.isChecked()==true){
            all.clear();
            //É adicionado cada id ao array list
            for(int i=0 ; i<listViewSocios.getCount() ; i++){
                listViewSocios.setItemChecked(i, true);

            }
        }

All the checkbox's in each row are checked but i want also enabled all this checkbox Can you help me? thanks


I try this way but don't work....

 for(int i=0 ; i<listViewSocios.getCount() ; i++){
                listViewSocios.setItemChecked(i, true);
                CheckBox cb = (CheckBox)listViewSocios.getChildAt(i).findViewById(android.R.id.text1);
                cb.setEnabled(false);
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Ricardo Filipe
  • 435
  • 4
  • 8
  • 24
  • 1
    You want to block or to enable the CheckBox?? – iTurki Aug 31 '12 at 10:23
  • Check [Android Checkbox listview select all (disable/enable)](http://stackoverflow.com/questions/4553186/android-checkbox-listview-select-all-disable-enable) – Ali Aug 31 '12 at 10:26
  • I want setEnabled(true); for all of the checkbox of listview. But i don't know how i do to all of them.. – Ricardo Filipe Aug 31 '12 at 10:29

2 Answers2

2

Disable your checkbox click event by this code

theCheckBox.setClickable(false);
Vishal Pawar
  • 4,324
  • 4
  • 28
  • 54
0

I solved the problem....

for(int i=0 ; i<listViewSocios.getCount() ; i++){
    listViewSocios.setItemChecked(i, true);
    CheckedTextView cb = (CheckedTextView)listViewSocios.getChildAt(i).findViewById(android.R.id.text1);
    cb.setEnabled(false);
 }

I don't remember how pass for each child of listView. But I remembered. XD

Thanks for your time.... :)

Ricardo Filipe
  • 435
  • 4
  • 8
  • 24