Multiple choice ListView and buttons: focus issues
<p>I'm quite new to Android and I'm trying to use a custom multiple choice listview whose items are defined as follows:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;com.jroy.android.views.CheckableLinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:gravity="left|center_vertical"&gt;
    &lt;CheckBox
        android:id="@+id/checkbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:background="@drawable/checkbox_selector"
        android:button="@null" /&gt;
    &lt;TextView
        android:id="@+id/name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" /&gt;
    &lt;Button
        android:id="@+id/btn_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:background="@drawable/button_view_selector" /&gt;
&lt;/com.jroy.android.views.CheckableLinearLayout&gt;
</code></pre>

<p>The choice mode of the ListView is set to 'multipleChoice' and CheckableLinearLayout is a subclass of LinearLayout which implements the Checkable interface the following way:</p>

<pre><code>public class CheckableLinearLayout extends LinearLayout implements Checkable {

    private Checkable mCheckable;                  

    @Override
    protected void onFinishInflate() {

        super.onFinishInflate();

        // Find checkable view
        for (int i = 0, childCount = getChildCount(); i &lt; childCount; ++i) {
            View v = getChildAt(i);
            if (v instanceof Checkable) {
                mCheckable = (Checkable) v;
                v.setFocusable(false);
                v.setClickable(false);
                break;
            }
        }

    }

    public CheckableLinearLayout(Context context) {
        super(context);
    }

    public CheckableLinearLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean isChecked() {
        return (mCheckable != null)
                ? mCheckable.isChecked()
                : false;
    }

    @Override
    public void setChecked(boolean checked) {
        if (mCheckable != null) {
            mCheckable.setChecked(checked);
        }
    }

    @Override
    public void toggle() {
        if (mCheckable != null) {
            mCheckable.toggle();
        }
    }

}
</code></pre>

<p>The problem is that I can't check any item, it seems like the buttons only can have the focus. I tried different things about focus but I didn't manage to get it work correctly...</p>

<p>What is the correct way to do what I try to achieve ?
Thanks,</p>
