Reputation: 1518
I've been searching all over for an example of the XML needed to setup a ListView to use a checkbox. While I've been able to find the Java code needed, the XML for the list items remains surprisingly elusive. Are there any good resources to learn how to style these listitems appropriately?
When I tried modifying the base XML file I have, I got the following error:
java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
So I'm not sure how to create it on my own using more elements than just a TextView. So currently, I am using the integer value found here as the resource ID for the ArrayAdapter: http://developer.android.com/reference/android/R.layout.html#simple_list_item_checked
which looks like what I want, but I need to be able to find the XML for that resource and style it for my own needs. Any help would be greatly appreciated!
Upvotes: 0
Views: 1032
Reputation: 2415
You can always create a layout of your own and inflate the same. But, for this you need to write a customized code for Adapter.
Here is one good example to start.
Upvotes: 0
Reputation: 1518
Found it!
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:checkMark="?android:attr/textCheckMark"
android:paddingLeft="6dip"
android:paddingRight="6dip"
/>
Upvotes: 1