title: How to Handle Button Clicks ListFragment
body: <p>I was curious how best to handle button clicks, inside of a <code>ListFragment</code> with a custom adapter. </p>
  
  <p>I have an <code>onClickListener</code> setup for the buttons, but I need to be able to get the item that it was clicked from, since it is within an item, here is the <code>getView</code> inside the custom adapter. </p>
  
  <pre><code>*/
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          View view;
  
          if (convertView == null) {
              view = _inflater.inflate(R.layout.test_single_item, parent, false);
          } else {
              view = convertView;
          }
  
          TestItemModel item = getItem(position);
          ((TextView) view.findViewById(R.id.item_label)).setText(item.getName());
          ((TextView) view.findViewById(R.id.item_id)).setText(item.getId());
          ImageView image = (ImageView) view.findViewById(R.id.image_id);
          Resources resources = this.getContext().getResources();
          image.setImageDrawable(resources.getDrawable(R.drawable.ic_launcher));
          Button btn = (Button) view.findViewById(R.id.button_id);
          Button btn2 = (Button) view.findViewById(R.id.button_id_2);
          Button btn3 = (Button) view.findViewById(R.id.button_id_3);
          ol = new OnItemClickListener(position);
          btn.setOnClickListener(ol);
          btn.setTag(1);
          btn2.setOnClickListener(ol);
          btn2.setTag(2);
          btn3.setOnClickListener(ol);
          btn3.setTag(3);
  
          return view;
      }
  </code></pre>
  
  <p>as you can see I used tags to determine which button was clicked and the <code>OnItemClickListener</code> knows where the position is from the position at which is being called. </p>
  
  <p>I am not sure about the best approach and how to go about doing this properly.</p>