Checkboxes in listview do not work sometimes
<p>I have a dialog that contains listview with checkboxes and a button that becomes visible if at least one checkbox is checked. Click on the button removes checked lines from the listview. But in this dialog I have a strange behaviour of the checkboxes in the list. For instance, if the list contains four lines, and I check one of them no more items can be checked anymore. If I add more items into the list then I can check more than one, but if I remove some items, remaining items become uncheckable.</p>

<p>PS. Is there a way to fix or workaround it anyhow?</p>

<p>UPDATE1: I found out that checkboxes do not become absolutelly inactive and if to try to click one several times it can become checked. It looks like area around the check box that is recognized as onClick area is set too little.</p>

<p>UPDATE2: Also I found out that if I comment this line from the dialog initialization code</p>

<p>getWindow ().setLayout (LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);</p>

<p>then all the checkboxes in the list become uncheckable right after dialog instantiation.</p>

<p>Dialog layout</p>

<pre><code>&lt;LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:minHeight="200dip"
  android:orientation="vertical"
  android:background="@android:color/white"
&gt;
  &lt;ListView
    android:id="@+id/list_view"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="1"
    android:divider="@color/list_divider"
    android:dividerHeight="2px"
    android:focusable="false"
    android:clickable="false"
    android:choiceMode="multipleChoice"
    /&gt;
  &lt;LinearLayout
    android:id="@+id/buttons_pane"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:visibility="gone"
  &gt;
    &lt;Button
      android:id="@+id/misc_list_remove_btn"
      android:layout_width="fill_parent"
      android:layout_height="48dip"
      android:text="@string/remove"
    /&gt;
  &lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>Item layout</p>

<pre><code>&lt;LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="47dip"
  android:orientation="horizontal"
  android:background="@android:color/white"
&gt;
  &lt;CheckBox
    android:id="@+id/misc_selectable_list_item_chk"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:checked="false"
  /&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>I create the dialog this way</p>

<pre><code>public ShowSelectableListDialog (Activity context, int titleId)
{
    super (context);
    setContentView (R.layout.misc_selectable_list_dlg);
    setTitle (titleId);
    getWindow ().setLayout (LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    adapter_ = setupListAdapter (getInitialValues (), context);
    ListView listView = (ListView)findViewById (R.id.list_view);
    listView.setAdapter (adapter_);
    listView.setItemsCanFocus (false);
    Button removeButton = (Button)findViewById (R.id.misc_list_remove_btn);
    removeButton.setOnClickListener (this);
  }
</code></pre>

<p>and item in the list</p>

<pre><code>@Override
protected View instantiateView (Object ... params)
{
  String title = (String)params[0];
  CompoundButton.OnCheckedChangeListener checkedChangeListener =
    (CompoundButton.OnCheckedChangeListener)params[1];

  LayoutInflater inflater = Utils.getInflater (getContext ());
  View view = inflater.inflate (R.layout.misc_selectable_list_item, null);
  view.setId (title.hashCode ());
  CheckBox chk = (CheckBox)view.findViewById (R.id.misc_selectable_list_item_chk);
  chk.setText (title);
  chk.setOnCheckedChangeListener (checkedChangeListener);
  return view;
}
</code></pre>
