title: Call a fragment onClick in CardView in Android
body: <p>Just want to call a fragment onClick on a Card.I hav tried all of the handful solutions available but nothing seems to work. here is my code for CardArrayAdapter</p>
  
  <pre><code>package com.example.cards;
  import java.util.ArrayList;
  import java.util.List;
  import android.app.FragmentManager;
  import android.app.FragmentTransaction;
  import android.content.Context;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.TextView;
  public class CardArrayAdapter  extends ArrayAdapter&lt;Card&gt; {
  private static final String TAG = "CardArrayAdapter";
  private List&lt;Card&gt; cardList = new ArrayList&lt;Card&gt;();
  public View row;
  
  static class CardViewHolder {
      TextView line1;
      TextView line2;
       TextView line3;
  }
  
  public CardArrayAdapter(Context context, int textViewResourceId) {
      super(context, textViewResourceId);
  }
  
  @Override
  public void add(Card object) {
      cardList.add(object);
      super.add(object);
  }
  
  @Override
  public int getCount() {
      return this.cardList.size();
  }
  
  @Override
  public Card getItem(int index) {
      return this.cardList.get(index);
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
       row = convertView;
      CardViewHolder viewHolder;
      if (row == null) {
          LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          row = inflater.inflate(R.layout.list_item_card, parent, false);
          viewHolder = new CardViewHolder();
          viewHolder.line1 = (TextView) row.findViewById(R.id.line1);
          viewHolder.line2 = (TextView) row.findViewById(R.id.line2);
        //  viewHolder.line3 = (TextView) row.findViewById(R.id.line3);
  
          row.setTag(viewHolder);
      } else {
          viewHolder = (CardViewHolder)row.getTag();
      }
      Card card = getItem(position);
      viewHolder.line1.setText(card.getLine1());
      viewHolder.line2.setText(card.getLine2());
    //  viewHolder.line3.setText(card.getLine3());
      return row;
  }
  
  public Bitmap decodeToBitmap(byte[] decodedByte) {
      return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
  }
  
  
  public void onListItemClick(int position, View convertView, ViewGroup parent) {             
  
        String passTitle = ((TextView)  row.findViewById(R.id.line1)).getText().toString();
        String passURL = ((TextView) row.findViewById(R.id.line2)).getText().toString();
  
        DetailFragment fragment2 = new DetailFragment();
           Bundle args = new Bundle();
  
           args.putString("title", passTitle);
           args.putString("url", passURL);
           fragment2.setArguments(args);  
  
           FragmentManager fragmentManager = getFragmentManager();
              FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
              fragmentTransaction.replace(R.id.frame_container, fragment2);
              fragmentTransaction.addToBackStack(null);
              fragmentTransaction.commit();
          }}
  </code></pre>
  
  <p>just want to know what to use instead of <code>getFragmentManager()</code> to call a fragment coz it shows error of <code>getFragmentManager() is undefined for the type CardArrayAdapter</code> and it is the only error in this java file.</p>