Listview Custom Layout Multiple Choice

Martayy

New Member
All,I would like to create a listview that allows multiple choice. The typical solutions is to get a cursor and use the SimpleCursorAdapter.\[code\] SimpleCursorAdapter adapter2 = new SimpleCursorAdapter(this, R.layout.simple_list_item_multiple_choice, cur2, cols2, views2);\[/code\]I am able to get this working when using the R.layout.simple_list_item_multiple_choice. I get the checkmarks to work when multiple items are selected.So I decided to try it with a custom made layout. Here is the xml code for my layout.\[code\]<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" /> <TextView android:id="@+id/lookup" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" /> <TextView android:id="@+id/hasphone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" /> <CheckedTextView android:id="@+id/checkedTextView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checkMark="?android:attr/listChoiceIndicatorMultiple"/></LinearLayout>\[/code\]So here is my issue. The layout is inflated fine using the same code and setting the ChoiceMode to multiple on my listview. The data from the cursor is populated fine.However, the issue I have is that the checkmarks do not show up as selected (a check in the box) when I click on the item. Is there something I am missing that would not involve creating a custom adapter?Any help would be appreciated.Thanks\[code\]l2.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);\[/code\]l2 is my listview.
 
Back
Top