title: getting position of click and custom button inside a list using custom CursorAdapter
body: <p><strong>Scenario</strong>
  Friends I have a ListView which I am using in a FrameLayout which will power my DrawerLayout for the sliding menu. I have custom buttons and text in my ListView which are defined as listitems in seperate xml. Now I am providing data to this ListView using a customAdapter which is extends CursorAdapter...</p>
  
  <p>I want to get the position of the click and also the button click events to fetch data accordingly... my code below...</p>
  
  <p><strong>List item XML</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent" 
      android:descendantFocusability="blocksDescendants"
      &gt;
  
  
       &lt;!--  ToggleButton
          android:id="@+id/button"
          android:layout_width="30dp"
          android:layout_height="30dp"
          android:layout_margin="10dp"
          style="@style/toggleButton"
          android:background="@drawable/silent_button_selector"
          android:focusable="false"
           /&gt; --&gt; 
  
      &lt;ImageButton
          android:id="@+id/button"
          android:layout_width="50dp"
          android:layout_height="50dp"
          android:layout_margin="10dp"
          android:src="@drawable/icon_button"
          /&gt;
  
  
      &lt;TextView 
          android:id="@+id/calendarName"
          android:layout_width="wrap_content"
          android:layout_margin="10dp"
          android:layout_height="wrap_content"
          android:textSize="25sp"
          android:layout_toRightOf="@+id/button"
          /&gt;
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>Adapter class:</strong></p>
  
  <pre><code>public class CalendarListAdapter extends CursorAdapter implements OnClickListener{
  
      @SuppressWarnings("deprecation")
      public CalendarListAdapter(Context context, Cursor c) {
          super(context, c);
          // TODO Auto-generated constructor stub
      }
  
      @Override
      public void bindView(View view, Context context, Cursor cursor) {
          // TODO Auto-generated method stub
          TextView title = (TextView) view.findViewById(R.id.calendarName);
          System.out.println("cursor details"
                  + cursor.getString(cursor.getColumnIndex(cursor
                          .getColumnName(1))));
          title.setText(cursor.getString(cursor.getColumnIndex(cursor
                  .getColumnName(1))));
          Log.d("click position " , "position is " +cursor.getPosition() );
          ImageButton button = (ImageButton) view.findViewById(R.id.button);
          button.setOnClickListener(this);
          Log.d("click position " , "position is " +cursor.getPosition() );
      }
  
      @Override
      public View newView(Context context, Cursor cursor, ViewGroup parent) {
          // TODO Auto-generated method stub
          LayoutInflater inflater = (LayoutInflater) context
                  .getSystemService(context.LAYOUT_INFLATER_SERVICE);
  
          View calendarListView = inflater.inflate(R.layout.calendar_list_item, null);
  
          return calendarListView;
      }
  
      @Override
      public void onClick(View view) {
          // TODO Auto-generated method stub
  
          Log.d("item clicked", "clicked" );
  
      }
  
  }
  </code></pre>
  
  <p><strong>What is happening now :</strong></p>
  
  <p>with the above implementation, when I click button it give only button click events and when I click rows/list items I get the position alone.</p>
  
  <p><strong>What I need to do?</strong> </p>
  
  <p>I need to get the position and the click event simultaneously so when I click button on 3rd row, i need position 3 and button clicked event...</p>
  
  <p>Please let me know the best way to do this... Thanks for your time and efforts..</p>