Adam
Adam

Reputation: 2570

Select multiple items in ListFragment

How do you set the ListView in a ListFragment to multiple choice? In a standard activity, I would specify android:choiceMode="multipleChoice" in the xml file, and use android.R.layout.simple_list_item_activated_1 as the textViewResourceId while attaching the adapter and all works fine, but in the ListFragment, the items selected are not being highlighted as they should with android.R.layout.simple_list_item_activated_1 and the choice mode is singleChocie.

Upvotes: 1

Views: 3376

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006584

How do you set the ListView in a ListFragment to multiple choice?

getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE) from Java, or provide your own layout file that uses android:choiceMode="multipleChoice" in the ListView, in addition to your adapter setup.

Upvotes: 7

Related Questions