title: ListFragment with buttons for each row
body: <p>I have an app, pretty much as this:</p>
  
  <p><img src="https://i.stack.imgur.com/TqTtf.png" alt="enter image description here"></p>
  
  <p>I have tried to follow this <a href="http://developer.android.com/guide/components/fragments.html" rel="nofollow noreferrer">http://developer.android.com/guide/components/fragments.html</a> (Creating event callbacks to the activity) But it seems it doesn't work. I mean, I would like to select each row for see details and also I want to be able to click in button a, b or c of any row I want. I'm not sure how to relate a button with its row.</p>
  
  <p>So this is my rowLayout.xml:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:orientation="horizontal" &gt;
  
  &lt;TableLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:stretchColumns="0,1"&gt;
  
      &lt;TableRow
          android:layout_width="match_parent"
          android:layout_height="wrap_content" &gt;
  
          &lt;LinearLayout
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:gravity="left"&gt;
  
              &lt;ImageView
                  android:id="@+id/imageViewTypeClient"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  tools:ignore="ContentDescription" /&gt;
  
              &lt;TextView
                  android:id="@+id/textView1"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;TextView
                  android:id="@+id/textView2"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="5dp"/&gt;
          &lt;/LinearLayout&gt;
  
          &lt;LinearLayout 
              android:gravity="right"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"&gt;
  
              &lt;ImageButton
                  android:id="@+id/imageButtonSync"
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:src="@android:drawable/stat_notify_sync"/&gt;
  
              &lt;ImageButton
                  android:id="@+id/imageButtonDelete"
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:src="@android:drawable/ic_menu_delete"
                  tools:ignore="ContentDescription" /&gt;
  
              &lt;ImageButton
                  android:id="@+id/imageButtonEdit"
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:src="@android:drawable/ic_menu_edit" /&gt;
  
          &lt;/LinearLayout&gt;
      &lt;/TableRow&gt;
  
  &lt;/TableLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>I made this way to get the order what I want. </p>
  
  <p>This is my ListFragment:</p>
  
  <pre><code>public class AplicacionActivity extends FragmentActivity implements OnEmployeeSelectedListener {
  
  
  public void onEmployeeSelected(int id) {
      Log.e("activity aplicacion", "entre");
      Bundle arguments = new Bundle();
      arguments.putLong("id", id);
      DataClientActivity fragment = new DataClientActivity();
      fragment.setArguments(arguments);
      getSupportFragmentManager().beginTransaction()
              .replace(android.R.id.tabcontent,fragment, AplicacionActivity.tagFragmentDataClient)
              .commit();
  }
  ...
  
  }
  </code></pre>
  
  <p>And this is my ListFragment:</p>
  
  <pre><code>public class ClientsActivity extends ListFragment {
  
  
  OnEmployeeSelectedListener mEmployeeListener;
  
  public interface OnEmployeeSelectedListener {
          public void onEmployeeSelected(int id);
  }
  
  @Override
  public void onAttach(Activity activity) {
      super.onAttach(activity);
      try {
          mEmployeeListener = (OnEmployeeSelectedListener) activity;
      } catch (ClassCastException e) {
          throw new ClassCastException(activity.toString() + " you must implement OnEmployeeSelectedListener");
      }
  }
  
  @Override
  public void onListItemClick(ListView l, View v, int position, long id) {
  
      int idEmployee = position;  
      // Send the event and Uri to the host activity
      mEmployeeListener.onEmployeeSelected(idEmployee);
  }
  </code></pre>
  
  <p>I was just trying to run this but the onListItemClick is not called when I press any row of my list.
  Despite of this, I dont know if I have to do something similar for the press buttons. </p>
  
  <p>If anyone can provide me a tutorial or put me in the right direction I'll really apreciate it.</p>