title: how to change the image of a particular row in list view
body: <p>I have a listview with each row having an image and an image button. When ever we click on that button it should  pick an image from image gallery from the device and should replace the image of that particular row.</p>
  
  <p>I can able to pick the image from gallery but it is replacing the image of last row instead of<br>
  replacing the image of the row from where we pressed the button.</p>
  
  <p>Please provide me some solution for this</p>
  
  <p>Here I'm attaching the code</p>
  
  <pre><code>public class FirstActivity extends Activity {
  String[] names;
  CustomAdapter adapter;
  private static int RESULT_LOAD_IMAGE = 1;
  ListView lv;
  int a;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_first);
      Resources res = getResources();
      names = res.getStringArray(R.array.names);
      adapter = new CustomAdapter(this, names);
      lv = (ListView) findViewById(R.id.listView);
      lv.setAdapter(adapter);
  
  }
  
  public void removeAtomPayOnClickHandler(View v) {
      Intent i = new Intent(
              Intent.ACTION_PICK,
              android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        a=lv.getPositionForView(lv);
        Toast.makeText(this, "---"+a, Toast.LENGTH_SHORT).show();
      startActivityForResult(i, RESULT_LOAD_IMAGE);
  }
  
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
  
      if (requestCode == RESULT_LOAD_IMAGE &amp;&amp; resultCode == RESULT_OK &amp;&amp; null != data) {
          Uri selectedImage = data.getData();
          String[] filePathColumn = { MediaStore.Images.Media.DATA };
  
          Cursor cursor = getContentResolver().query(selectedImage,
                  filePathColumn, null, null, null);
          cursor.moveToFirst();
  
          int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
          String picturePath = cursor.getString(columnIndex);
          cursor.close();
           CHolder.tv.setImageBitmap(BitmapFactory.decodeFile(picturePath));
        //  ImageView imageView = (ImageView) findViewById(R.id.imgView);
          //imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));
  
      }
  
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and the code for adapter class</p>
  
  <pre><code>      public class CustomAdapter extends ArrayAdapter&lt;String&gt;{
        Context context;
        String[] input;
        public CustomAdapter(Context c, String[] values) {
      super(c, R.layout.atom_pay_list_item, values);
      this.context = c;
      this.input = values;
      // TODO Auto-generated constructor stub
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      // TODO Auto-generated method stub
      View row = convertView;
      CHolder holder = null;
      if(row == null)
      {
          LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          row = inflater.inflate(R.layout.atom_pay_list_item, parent, false);
          holder = new CHolder(row);
          row.setTag(holder);
      }
      else{
          holder = (CHolder) row.getTag();
      }
  
      //holder.tv.setImageDrawable(drawable)(input[position]);
      ///iv.setImageDrawable(R.drawable.abc_ic_search);
      return row;
  }
  static class CHolder{
      public static ImageView tv;
      public static ImageButton iv;
      CHolder(View v)
      {
          tv = (ImageView) v.findViewById(R.id.textview);
          iv = (ImageButton) v.findViewById(R.id.imageview);
      }
  }
  </code></pre>
  
  <p>}</p>