List with buttons - only first button registers
<p>I have implemented a ListView, each element of which contains a checkbox and a button. I have written an adapter for the view as follows:</p>

<pre><code>public class myadapter extends SimpleAdapter
{
    LayoutInflater mLayoutInflater;

    public myadapter(Context context, List&lt;? extends Map&lt;String, ?&gt;&gt; data, int resource, String[] from, int[] to)
    {
        super(context, data, resource, from, to);
        mLayoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) 
    {
        View view = null;

        Log.i("xx","getView called: position="+position);

        if (convertView != null)
        {
            view = convertView;
        } 
        else 
        {      
            view = mLayoutInflater.inflate(R.layout.custom_row_view, parent, false);
        }

        Button buttonEdit = (Button) view.findViewById(R.id.editbut);
        CheckBox cb = (CheckBox)view.findViewById(R.id.checkbox);

        buttonEdit.setOnClickListener(new OnClickListener()
        {   
            public void onClick(View arg0)
            {
                Log.i("xx","Button pressed! position ="+position);
            }
        });
        cb.setOnCheckedChangeListener(new OnCheckedChangeListener()
        {
            @Override
            public void onCheckedChanged(CompoundButton arg0, boolean arg1) 
            {
                Log.i("xx","Checkbox changed! position ="+position);
            }
          });

        return super.getView(position, convertView, parent);
    }
}
</code></pre>

<p>At runtime, if I click on a button in the top row of my list I always see "Button pressed! position = 0" in the log output. Similarly, if I click on the checkbox I see "Checkbox changed! position=0". The problem comes if I click on a button on any other element in the list. Sometimes I see the correct log message, but other times I see nothing at all. Any ideas?</p>

<p><strong>EDIT:</strong> here's my custom_row_view.xml:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"&gt;

    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" &gt;

        &lt;LinearLayout
            android:layout_width="142dp"
            android:layout_height="wrap_content"
            android:orientation="vertical" &gt;
            &lt;TextView android:id="@+id/text1"         
                android:textSize="16sp"         
                android:textStyle="bold" 
                android:textColor="#FFFF00"        
                android:layout_width="match_parent"         
                android:layout_height="fill_parent"/&gt;
            &lt;TextView android:id="@+id/text2"         
                android:textSize="12sp"         
                android:textStyle="bold"      
                android:layout_width="match_parent"         
                android:layout_height="fill_parent"/&gt;
            &lt;TextView android:id="@+id/text3" 
                android:typeface="sans"
                android:textSize="14sp"
                android:textStyle="italic"
                android:layout_width="match_parent" 
                android:layout_height="wrap_content"/&gt;

        &lt;/LinearLayout&gt;

    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="right" &gt;



    &lt;CheckBox
        android:id="@+id/checkbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
                    android:focusable="false"
            android:focusableInTouchMode="false"
        android:text="" /&gt;
        &lt;Button
            android:id="@+id/editbut"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:text="Edit" /&gt;
        &lt;/LinearLayout&gt;
    &lt;/LinearLayout&gt;



&lt;/LinearLayout&gt;
</code></pre>
