title: error on frament listview using arrayadapter gives me error getFragmentManager() is undefined for the type new View.OnClickListener(){}
body: <p>I am using listfragment where i am extending arrayadapter to my customadapter class i am getting error </p>
  
  <pre><code>The method getFragmentManager() is undefined for the type new View.OnClickListener(){}
  </code></pre>
  
  <p>Here is my adapter class </p>
  
  <p>package com.arivoli.adapters;</p>
  
  <pre><code>import java.util.ArrayList;
  import android.app.Activity;
  import android.app.Fragment;
  import android.app.FragmentManager;
  import android.app.FragmentTransaction;
  import android.content.Context;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.ImageButton;
  import android.widget.ListView;
  import android.widget.TextView;
  import com.arivoli.amec.Contactrepresentativedetails;
  import com.arivoli.amec.R;
  
  
  public class CustomAdapter extends ArrayAdapter&lt;String&gt; {
  
  private Context context;
  ListView list;
  private ArrayList&lt;String&gt; listexample;
  
  public CustomAdapter(Context con, int layout, ArrayList&lt;String&gt; listexample) {
      super(con, com.arivoli.amec.R.layout.contactrepresentativelist,
              listexample);
      this.context = con;
      this.listexample = listexample;
  }
  
  public View getView(final int position, View convertView, ViewGroup parent) {
      LayoutInflater inflater = (LayoutInflater) context
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View rowView = inflater.inflate(R.layout.contactrow, parent, false);
      TextView tv = (TextView) rowView.findViewById(R.id.textView1);
      ImageButton i = (ImageButton) rowView.findViewById(R.id.imageView1);
      tv.setText(listexample.get(position));
  
      i.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
      Contactrepresentativedetails fragment = new Contactrepresentativedetails();
  
      FragmentManager fm = ((Activity)context).getFragmentManager();
              FragmentTransaction transaction = fm.beginTransaction();
  
              transaction.replace(R.id.contactcontainer, fragment);
              transaction.addToBackStack(null);
              transaction.commit();
          }
      });
      return rowView;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>my main class</p>
  
  <pre><code> public class Contactrepresentative extends Fragment{
  
      CustomAdapter ca;
      ListView list;
      private ArrayList&lt;String&gt; listexample; 
  
  
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          // TODO Auto-generated method stub
      View view = inflater.inflate(R.layout.contactrepresentativelist, container, false);
            list=(ListView)view.findViewById(R.id.contactrepresentativelist1);
            listexample=new ArrayList&lt;String&gt;();
            getlist();
            ca = new CustomAdapter(getActivity(), R.layout.contactrepresentativelist,   
                                                                           listexample);
          list.setAdapter(ca);
      }
  
      private void getlist() {
          // TODO Auto-generated method stub
          listexample.add("Rep. Name (R)");
          listexample.add("Rep. Name (R)");
          listexample.add("Rep. Name (R)");
          listexample.add("Rep. Name (R)");
          listexample.add("Rep. Name (R)");
          listexample.add("Rep. Name (D)");
          listexample.add("Rep. Name (D)");
          listexample.add("Rep. Name (R)");
          listexample.add("Rep. Name (R)");
          listexample.add("Rep. Name (D)");
          listexample.add("Rep. Name (R)");
          listexample.add("Rep. Name (D)");
          listexample.add("Rep. Name (R)");
      }
  }
  </code></pre>
  
  <p>it displays list of items when i click on any item it should replace the present fragment for that i am using</p>
  
  <pre><code>Fragment fragment = new Contactrepresentativedetails();
  
          FragmentManager fm = getFragmentManager(); 
                      // here i am getting error can any one help me how to slove 
                      // this issue 
          FragmentTransaction transaction = fm.beginTransaction();
  
          transaction.replace(R.id.contactcontainer, fragment);
          transaction.addToBackStack(null);
          transaction.commit();
  </code></pre>
  
  <p>my imports in adapter class</p>
  
  <pre><code>import java.util.ArrayList;
  
  
  import com.arivoli.amec.R;
  
  import android.content.Context;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.ImageButton;
  import android.widget.ListView;
  import android.widget.TextView;
  </code></pre>