title: How to use onActivityResult in base adapter class?
body: <p>I have a <code>listview</code> which contains two <code>buttons</code>, when the <code>button</code> is clicked it should open a gallery. I tried to implement it and followed some post on stackoverflow but still I'm not able to get exact result. How to open the gallery using buttons in listView<code>listview</code>?</p>
  
  <p>I have tried the following and used the adapter class as inner class</p>
  
  <pre><code>MyAdapter adapter=new MyAdapter(getApplicationContext(),videoFileList);
  </code></pre>
  
  <p>im my adapter class</p>
  
  <pre><code> private class MyAdapter extends BaseAdapter
          {
  
           ImageView picture;
           Button imgbtn,videobtn;
           ImageButton play;
              Context context;
              private LayoutInflater inflater;
              private ArrayList&lt;String&gt; videolisty;
              public MyAdapter(Context context,ArrayList&lt;String&gt; videolistx)
              {
                  this.context=context;
                  inflater = LayoutInflater.from(context);
                  videolisty = videolistx;
                  Field[] arrayOfField = R.raw.class.getFields();
                  for (int i = 0; ; i++)
                  {
                    if (i &gt;= arrayOfField.length)
                    {
                      System.out.println("-----------videolist------" +videoFileList);
                      return;
                    }
                    System.out.println("audio files-----" + arrayOfField[i].getName());
                    videoFilename.add(arrayOfField[i].getName());
                    Uri localUri = Uri.parse("android.resource://" + Listmodels.this.getPackageName() + "/" + "R.raw." + arrayOfField[i].getName());
                    System.out.println("--------uri path------" + localUri);
                  }
  
              }
  
              @Override
              public int getCount() {
                  return videolisty.size();
              }
  
              @Override
              public Object getItem(int i)
              {
                  return videolisty.get(i);
              }
  
              @Override
              public long getItemId(int i)
              {
                  return i;
              }
  
              @Override
              public View getView(int i, View view, ViewGroup viewGroup)
              {
                  View v = view;
  
                  final int xx = i;
                  if(v == null)
                  {
                     v = inflater.inflate(R.layout.clistview, viewGroup, false);
                     v.setTag(R.id.categoryimageView1, v.findViewById(R.id.categoryimageView1));
                     v.setTag(R.id.uploadimg, v.findViewById(R.id.uploadimg));
                     v.setTag(R.id.uploadvideo, v.findViewById(R.id.uploadvideo));
                     v.setTag(R.id.play, v.findViewById(R.id.play));
                  }
  
                  picture = (ImageView)v.getTag(R.id.categoryimageView1);
                  imgbtn = (Button)v.getTag(R.id.uploadimg);
                  videobtn = (Button)v.getTag(R.id.uploadvideo);
                  play=(ImageButton)v.getTag(R.id.play);
                  imgbtn.setOnClickListener(new OnClickListener() {
  
                      @Override
                      public void onClick(View v) {
                          // TODO Auto-generated method stub
                          Intent i = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                            Activity aa = (Activity)context;
                           aa.startActivityForResult(i, RESULT_LOAD_IMAGE);
                      }
  
  
  
  
  
                  });
  
                  play.setOnClickListener(new View.OnClickListener() {
  
                      @Override
                      public void onClick(View arg0) {
                          // TODO Auto-generated method stub
                          System.out.println("YEST"+xx);
                          Intent localIntent = new Intent(Listmodels.this, Videoplay.class);
                          localIntent.putExtra("videopath", videoFileList.get(xx));
                          startActivity(localIntent);
                      }
                  });
  
                  /*picture.setImageResource(item.drawableId);
                  name.setText(item.name);*/
  
  
                  return v;
              }
  
              protected void onActivityResult(int requestCode, int resultCode) {
                  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();
  
                      System.out.println("------data path-------"+picturePath);
  
                      //filechoose.setText(picturePath);
  
                  }
  
  
  
  
  
  
          }
  </code></pre>