Reputation: 141
i try to create a multiplichoice listview, but i just can select one. Here is my code:
Selector (multiselect_background.xml):
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/blue" android:state_checked="true"/>
<item android:drawable="@color/red" android:state_pressed="true"/>
<item android:drawable="@color/grey"/>
</selector>
ListView (list.xml):
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="multipleChoice"
/>
Layout (select_item.xml):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/multiselect_background">
Somebody knows, why the multiselect isn't possible? Thanks a lot!!
Upvotes: 1
Views: 442
Reputation: 18243
I personally made a custom ListView, with an array of ITEMS and an array of booleans the same size (initialized at false).
Each time a cell is clicked, it colors it and saves its state in the array of booleans (b = !b).
Worked great. I guess you got the idea, no code needed. If so, please tell.
Upvotes: 1