Anyone please... On May 10, 6:34 pm, dillipk <codersnet2...@gmail.com> wrote: > Hello, > How do I get the selected items in a ListView which contains a multi > selelected check boxes.? The following code doesn't work correctly... > getContacts() is being called in a Button click(). > > private String getContacts(){ > > SparseBooleanArray selectedContacts = > listView.getCheckedItemPositions(); > StringBuffer sb = new StringBuffer(); > int size = selectedContacts .size(); > > for (int sbaKey = 0; sbaKey < size; sbaKey++) > { > if (selectedContacts .get(sbaKey, false)) > { > //Log.d(TAG, "Selected Categories : " + > listView.getItemAtPosition(sbaKey).toString()); > sb.append(listView.getItemAtPosition(sbaKey).toString()); > if(sbaKey <= size - 2 ){ > sb.append(','); > } > } > } > > Log.d(TAG, "Selected Contacts : " + sb.toString()); > return sb.toString(); > > } > > Creation: > > �...@override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > this.setTitle("Preferences"); > setListAdapter(new ArrayAdapter<String>(this, > android.R.layout.simple_list_item_multiple_choice, > CONTACTS)); > > listView = getListView(); > > listView.setItemsCanFocus(false); > listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); > > } > > Thank you for your help in advance.. > > -DK > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group > athttp://groups.google.com/group/android-developers?hl=en
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en