title: ListView onItemSelected Listener
body: <p>I wanted to show the image only at the selected row from listview. Here is the code:</p>
  
  <pre><code>private class ListAdapter extends BaseAdapter {
      LayoutInflater inflater;
      ViewHolder viewHolder;
  
      public ListAdapter(Context context) {
          inflater = LayoutInflater.from(context);
      }
  
      public int getCount() {
          return attendeeList.size();
      }
  
      public Object getItem(int position) {
          return position;
      }
  
      public long getItemId(int position) {
          return position;
      }
  
      public View getView(final int position, View convertView, ViewGroup parent) {
          if (convertView == null) {
  
              convertView = inflater.inflate(R.layout.attendee_listview_row,
                      null);
              viewHolder = new ViewHolder();
  
              viewHolder.txt_dName = (TextView) convertView
                      .findViewById(R.id.txtDisplayName);
  
              viewHolder.txt_dAddr = (TextView) convertView
                      .findViewById(R.id.txtDisplayAddr);
  
              viewHolder.txt_dtelNo = (TextView) convertView
                      .findViewById(R.id.txtDisplayTelNo);
  
              viewHolder.btn_scan = (ImageView) convertView.findViewById(R.id.btnScan);
              viewHolder.registered_tag = (ImageView) convertView.findViewById(R.id.ivRegisteredTag);
  
              convertView.setTag(viewHolder);
          } else {
              viewHolder = (ViewHolder) convertView.getTag();
          }
  
          viewHolder.txt_dName.setText(attendeeList.get(position)
                  .getAccountName().trim());
  
          viewHolder.txt_dAddr.setText(attendeeList.get(position)
                  .getAttendeeAddr().trim());
  
          viewHolder.txt_dtelNo.setText("Tel no: "
                  + attendeeList.get(position).getTelNo().trim());        
  
          viewHolder.btn_scan.setOnClickListener(new OnClickListener(){
              public void onClick(View v){
                  viewHolder.registered_tag.setVisibility(View.VISIBLE);
                  Intent intent = new Intent(
                          "com.google.zxing.client.android.SCAN");
                  intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
                  startActivityForResult(intent, 0);
  
              }
          });
  
          return convertView;
      }
  }
  </code></pre>
  
  <p>With these code, I am trying to show the registered_tag upon btn_scan onClick. However, the image is not really showing at the selected row. It shows at other row instead.</p>
  
  <p>Any ideas? Thanks in advance.</p>