0

I have a listview that is built from textviews with the built in Resource Layout simple_list_item_multiple_choice. syntax like this :

ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_multiple_choice, internet);

If the user clicks an item list, the checkbox of selected item has to be checked.

I know to implement OnItemClickListner, But after it what should I do to check the selected item.

1 Answers1

0

Yu can try this ,referred from https://stackoverflow.com/a/4590897/5193608.

SparseBooleanArray.get returns a boolean, but I believe you need to check it for each position in your list, e.g.

int len = listView.getCount();
SparseBooleanArray checked = listView.getCheckedItemPositions();
for (int i = 0; i < len; i++)
 if (checked.get(i)) {
  String item = cont_list.get(i);
  /* do whatever you want with the checked item */
 }
Community
  • 1
  • 1
Animesh Mangla
  • 773
  • 7
  • 31