title: Change image on click in custom listview Android
body: <p>In my custom listview I want to change Image when the image is clicked. 
  But currently when I click on Image, last row image is changed not the one on which I clicked.
  My customAdapter classis below:</p>
  
  <pre><code>package com.zek.androidvoicechanger;
  
  import java.util.List;
  
  import org.w3c.dom.Text;
  
  import android.app.Activity;
  import android.content.Context;
  import android.media.Image;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.CompoundButton;
  import android.widget.CompoundButton.OnCheckedChangeListener;
  import android.widget.ImageView;
  import android.widget.RadioButton;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class CustomAdapter extends ArrayAdapter&lt;Items&gt; {
  
      Context context;
      ImageView image ;
  
  
  //  int[] Radio = { R.drawable.play, R.drawable.pause };
  
      public CustomAdapter(Context context, int resourceId, List&lt;Items&gt; items) {
          super(context, resourceId, items);
          this.context = context;
      }
  
      private class ViewHolder {
          // ImageView imageView;
  
          TextView txtTitle;
  //      ImageView img;
  
      }
  
      public View getView(final int position, View convertView,
              final ViewGroup parent) {
  
          ViewHolder holder = null;
  
          Items rowItem = getItem(position);
  
          LayoutInflater mInflater = (LayoutInflater) context
                  .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
  
          if (convertView == null) {
              convertView = mInflater.inflate(R.layout.custom_list, null);
              holder = new ViewHolder();
  
              holder.txtTitle = (TextView) convertView
                      .findViewById(R.id.textView1);
  //          holder.img = (ImageView) convertView.findViewById(R.id.imageView2);
              image = (ImageView) convertView.findViewById(R.id.imageView2);
          //  holder.rdo = (RadioButton) convertView.findViewById(R.id.radioButton1);
              convertView.setTag(holder);
          } else
              holder = (ViewHolder) convertView.getTag();
  
          holder.txtTitle.setText(rowItem.getTitle());
  
          image.setImageResource(rowItem.getImageId());
          image.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  Toast.makeText(context, "image clicked", 1000).show();
                  if(position==0){
                  image.setImageResource(R.drawable.pause);
                  }
                  AudioListner.playRecord(position);
  
              }
          });
  
  
  
      //holder.rdo.setTag(position);
  //      holder.rdo.setOnCheckedChangeListener(new OnCheckedChangeListener() {
  //          
  //          @Override
  //          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  //
  //          
  //              
  //          }
  //      });
  
  //      rdo.setOnClickListener(new OnClickListener() {
  //
  //          @Override
  //          public void onClick(View v) {
  //
  //              
  //              if(position==0){
  //                  rdo.indexOfChild(findViewById(isEnabled(position)));
  //                  Toast.makeText(context, "image clicked", 1000).show();
  //                  rdo.setBackgroundResource(R.drawable.pause);
  //                  AudioListner.playRecord(position);
  //                  
  //              }
  //              
  //              
  //              
  //              if (rdo.isClickable()) {
  //                  rdo.setBackgroundResource(R.drawable.pause);
  //                  Toast.makeText(context, "image clicked", 1000).show();
  //
  //                  //Radio[1] = 1;
  //                  AudioListner.playRecord(position);
  //                  
  //              } else {
  //              //  rdo.setBackgroundResource(R.drawable.play);
  //                  Toast.makeText(context, "image not clicked", 1000).show();
  //
  //              }
  ////
  //          }
  //      });
  
          return convertView;
      }
  
  }
  </code></pre>
  
  <p>Any help will be appreciated. </p>