title: Android : Passing button click response from getView() method of adapter class to mainActivity
body: <p>The question is simple. I have written a seperate class which extends ArrayAdapter. This adapter deals with couple of TEXTVIEWs and a BUTTON. The problem is I am not sure whether I have take the response from Button's onClickListener written in getView() method to the main_activity. The main_activity has lot of logic to be followed based on the button response. Could you please let me know how to get the button response to main_activity ?</p>
  
  <p>Following is the getView method  </p>
  
  <pre><code>public View getView(final int position, View convertView, ViewGroup parent) {      
      ViewHolder holder;   
      int type = getItemViewType(position); 
  
      if (convertView == null) { 
          holder = new ViewHolder();  
          switch (type) {
          case 0:
              convertView = vi.inflate(R.layout.group,  null); 
              holder.menuItem = (TextView) convertView.findViewById(R.id.tvGroup);
              convertView.setBackgroundColor(Color.RED); 
              break;              
          case 1:
              convertView = vi.inflate(R.layout.confirmitem,  null); 
              holder.menuItem = (TextView) convertView.findViewById(R.id.tvConfirmItem); 
              holder.quantity = (TextView) convertView.findViewById(R.id.tvQuantity); 
              holder.cancel   = (Button)   convertView.findViewById(R.id.bCancel); 
  
              //   cancel button
                 holder.cancel.setOnClickListener(new View.OnClickListener() {        
                      public void onClick(View v) {                   
                          Log.i("ConfirmAdapter ","Button postion  "+ position + "canceled item : " + menuItemList.get(position).getTicketItemObject().getName() ); 
                          }       
                  });   
              break; 
           }  
          convertView.setTag(holder); 
      } else {
          holder = (ViewHolder) convertView.getTag();  
      }    
  
      switch (type) {
      case 0:         
          holder.menuItem.setText(menuItemList.get(position).getTicketItemObject().getCategoryName()) ; 
          convertView.setBackgroundColor(Color.RED);  
          break;              
      case 1:
          holder.menuItem.setText(menuItemList.get(position).getTicketItemObject().getName());
          holder.quantity.setText(Integer.toString(menuItemList.get(position).getTicketItemObject().getItemCount())); 
          break; 
       }
  
      return convertView; 
      }
  </code></pre>