Hello,
I have a list view with checkBoxes from android layout and myCheckBox.
I want when myCheckBox is selected to select all items from list view,
and when myCheckBox is unselected to unsellect all items from listView

here is a piece of my code:

final ListView listFriends = (ListView)
dialog.findViewById(R.id.listView_friends);


final ArrayAdapter<User> adapter = new
ArrayAdapter<User>(MyActivity.this,
android.R.layout.simple_list_item_multiple_choice, friendsList) {

                        @Override
                        public View getView(int position, View convertView, 
ViewGroup
parent) {
                                View row;

                                if (null == convertView) {
                                        row =
mInflater.inflate(android.R.layout.simple_list_item_multiple_choice,
null);
                                } else {
                                        row = convertView;
                                }

                                CheckedTextView tv = (CheckedTextView)
row.findViewById(android.R.id.text1);
                                
tv.setText(friendsList.get(position).getFBName());
                                ....
                                return row;
                        }


                };

listFriends.setAdapter(adapter);
listFriends.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);


I tried few possibilities () and none works:


CheckBox myCheckBox =
(CheckBox)dialog.findViewById(R.id.checkBox_all);
myCheckBox .setOnCheckedChangeListener(new OnCheckedChangeListener() {

                        @Override
                        public void onCheckedChanged(CompoundButton buttonView, 
boolean
isChecked) {
                                listFriends.setItemChecked(1, true);

                                 ListView list = (ListView)
dialog.findViewById(R.id.listView_specific_friends);

                                 for (int i=0; i < list.getCount(); i++) {
                     list.setItemChecked(i, true);
                 }


//                              final ListView listFriends = 
AddTour.this.getListView();
                                if (isChecked) {
                                        tvSelectAll.setText("UNSELECT ALL");

//                                      for (int i=0; 
i<listFriends.getAdapter().getCount(); i++) {
//                                              listFriends.setItemChecked(i, 
true);
////                                            
friendsList.get(i).setChecked(true);
//                                      }

                                }
                                else {
                                        
tvSelectAll.setText(Html.fromHtml("<font color=\"GREY\">UN</
font>SELECT ALL"));
//                                      for (int i=0; 
i<listFriends.getAdapter().getCount(); i++) {
//                                              listFriends.setItemChecked(i, 
false);
////                                            
friendsList.get(i).setChecked(false);
//                                      }
                                }
//                              adapter.notifyDataSetChanged();

                        }
                });

Is there are any posibility to select all checkboxes from
android.R.layout.simple_list_item_multiple_choice

Thank you for any help
Lidia

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to