title: How to get FragmentActivity reference inside an anonymous inner class of bindView method?
body: <p>I am trying to get a <code>FragmentActivity</code> reference inside an anonymous inner class of <code>bindView</code> method in a <code>CursorAdapter</code>. Actually I am trying to create a <code>DialogFragment</code> when an <code>ImageView</code> is clicked in my <code>ListView</code>, connected with a <code>SimpleCursorAdapter</code>.</p>
  
  <pre><code>@Override
      public void bindView(View view, Context context, Cursor c) {
          super.bindView(view, context, c);
  
          ImageView geoEditIcon = (ImageView)view.findViewById(R.id.li_cdf_icon_geoedit);
          geoEditIcon.setImageResource(R.drawable.geolist_edit);
          geoEditIcon.setTag(c.getString(c.getColumnIndex(DBConstants.ID)));
  
          geoEditIcon.setOnClickListener(new OnClickListener(){
              @Override
              public void onClick(View v) {
                Log.i("geolist", "geoEditIcon clicked");
                String selectedGeoID = v.getTag().toString();
                Log.i("geolist", "geoEditIcon selected Id-&gt;"+selectedGeoID);
  
                EditGeofenceFragment editGeofenceFragment = new EditGeofenceFragment(v.getContext(),selectedGeoID);
                //what context i want to use in Show method
                editGeofenceFragment.show(getActivity().getSupportFragmentManager(), "editGeofenceFragment");
              }
          });
      }
  </code></pre>
  
  <p><strong>Update :</strong></p>
  
  <p>I have passed getSupportFragmentManager reference to constructor of MySimpleCursorAdapter and use it in my anonymous inner class.That is my Dialog fragment show method. Now it works fine.I updated my code below.</p>
  
  <pre><code>public MySimpleCursorAdapter(Context context, FragmentManager fragmentManager, int layout, Cursor c,String[] from, int[] to, int flags) {
          super(context, layout, c, from, to, flags);
          this.context=context;
          this.fragmentManager=fragmentManager;
      }
  
  
      @Override
      public void bindView(View view, Context context, Cursor c) {
          super.bindView(view, context, c);
  
          ImageView geoEditIcon = (ImageView)view.findViewById(R.id.li_cdf_icon_geoedit);
          geoEditIcon.setImageResource(R.drawable.geolist_edit);
          geoEditIcon.setTag(c.getString(c.getColumnIndex(DBConstants.ID)));
  
          geoEditIcon.setOnClickListener(new OnClickListener(){
              @Override
              public void onClick(View v) {
                Log.i("geolist", "geoEditIcon clicked");
                String selectedGeoID = v.getTag().toString();
                Log.i("geolist", "geoEditIcon selected Id-&gt;"+selectedGeoID);
  
                EditGeofenceFragment editGeofenceFragment = new EditGeofenceFragment(v.getContext(),selectedGeoID);
                // Put fragmentManager in first parameter to show method.
                editGeofenceFragment.show(fragmentManager, "editGeofenceFragment");
              }
          });
      }
  </code></pre>