title: Implement onClick Listener in Custom BaseAdapter
body: <p>I have a list view of ticket items with multiple columns.  I'm trying to figure out how to implement an onclick listener with what I've written.</p>
  
  <p>Fragment_OpenTickets.java:</p>
  
  <pre><code>public class Fragment_OpenTickets extends Fragment {
  
  ArrayList&lt;HashMap&lt;String, String&gt;&gt; ticketList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
  @Override
  public View onCreateView(LayoutInflater inflater,
                           ViewGroup container, Bundle savedInstanceState) {
      Context context = getActivity();
      DBController dbc = new DBController(context);
      View view = inflater.inflate(R.layout.fragment_opentickets, container, false);
      ListView listView = (ListView) view.findViewById(R.id.openList);
      Cursor cursor = dbc.getAllOpenTickets();
  
      if (cursor.moveToFirst()) {
          do {
              HashMap&lt;String, String&gt; hashMap = new HashMap&lt;String, String&gt;();
              int size = cursor.getColumnCount();
              for (int i = 0; i &lt; size; i++) {
                  hashMap.put(cursor.getColumnName(i), cursor.getString(i));
              }
              ticketList.add(hashMap);
          } while (cursor.moveToNext());
      }
      Adapter_OpenList adapter = new Adapter_OpenList(ticketList, context);
      listView.setAdapter(adapter);
      dbc.close();
  
      return view;
  }
  }
  </code></pre>
  
  <p>Adapter_OpenList.java:</p>
  
  <pre><code>public class Adapter_OpenList extends BaseAdapter {
  ArrayList&lt;HashMap&lt;String, String&gt;&gt; ticketList;
  Context context;
  LayoutInflater mInflater;
  
  public Adapter_OpenList(ArrayList&lt;HashMap&lt;String, String&gt;&gt; arr, Context c){
      ticketList = arr;
      context = c;
      mInflater = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }
  
  @Override
  public int getCount() {
      // TODO Auto-generated method stub
      return ticketList.size();
  }
  
  @Override
  public Object getItem(int position) {
      // TODO Auto-generated method stub
      return ticketList.get(position);
  }
  
  @Override
  public long getItemId(int position) {
      // TODO Auto-generated method stub
      return 0;
  }
  
  public View getView(final int position, View convertView, ViewGroup parent) {
      ViewHolder holder;
  
      if(convertView == null) {
          convertView = mInflater.inflate(R.layout.fragment_openticket_row, null);
          holder = new ViewHolder();
          holder.txtTicketNo = (TextView)convertView.findViewById(R.id.row_ticketNo);
          holder.txtTicketDate = (TextView)convertView.findViewById(R.id.row_ticketDate);
          holder.txtLease = (TextView)convertView.findViewById(R.id.row_lease);
          holder.txtDelivLoc = (TextView)convertView.findViewById(R.id.row_delivLoc);
      } else {
          holder = (ViewHolder) convertView.getTag();
      }
  
      HashMap map = ticketList.get(position);
      holder.txtTicketNo.setText((CharSequence) map.get("ticketNo"));
      holder.txtTicketDate.setText((CharSequence) map.get("ticketDate"));
      holder.txtLease.setText((CharSequence) map.get("lease"));
      holder.txtDelivLoc.setText((CharSequence) map.get("delivLoc"));
  
      return convertView;
  }
  
  private class ViewHolder {
      TextView txtTicketNo;
      TextView txtTicketDate;
      TextView txtLease;
      TextView txtDelivLoc;
  }
  }
  </code></pre>
  
  <p>If the user taps on a ticket row in the list I need to get the SQLite id of the ticket to either view it or start the ticket.  I know there are different ways to do this, but I'm just trying to get the basics down so I can play with it.  Thanks!</p>
  
  <p><strong>UPDATE:</strong>
  I solved this by using code provided by Johan and removing a button I had in the fragment_openticket_row.xml file the adapter was using.  It was conflicting with the onClick.</p>