I have a simple list view that is attached to an array adapter. My list is a list of multi select checkboxes.
To start I just used android CheckedTextView for my lists text view:
public static class MyAdapter extends ArrayAdapter<String> {
private List<String> items;
public MyAdapter(Context context, List<String> items) {
super(context, android.R.layout.simple_list_item_multiple_choice, items);
this.items = items;
}
...
This works just great when I click a row the check box gets checked.
My view has gotten more complicated and I had a need to add a progress bar to each item in my list:
list_item.xml
<?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="wrap_content"
android:orientation="horizontal" >
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:indeterminate="true"
android:visibility="visible" />
<CheckedTextView
android:id="@+id/checkedTextView"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:gravity="center_vertical"
android:paddingLeft="6dip"
android:paddingRight="6dip"
android:text="Rivers"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
So my array adapter now looks like:
public static class MyAdapter extends ArrayAdapter<String> {
private List<String> items;
public MyAdapter(Context context, List<String> items) {
super(context, R.layout.list_item, R.id.checkedTextView, items);
this.items = items;
}
With that simple change to use my own layout "R.layout.list_item", when I click a row its checkbox does not get checked. What magic was happening before that made this work when I used androids "android.R.layout.simple_list_item_multiple_choice" layout?
I.E. somewhere android handled the click event and checked the box, but all I did is change the layout, and now it doesn't work. I imagine I got something for free by using there layout. Can I setup my layout differently to still get the free check on click?