title: Android Fragment How to navigate from custom listview baseadapter to Fargment?
body: <p>I want to ask how to navigate from <strong>Listview BaseAdapter</strong> to <strong>Fragment</strong>?
  I clicked any item and get position and info from it and send to Fragment. How can I do it?</p>
  
  <p>My BaseAdapter:</p>
  
  <pre><code>public class ListViewAdapter extends BaseAdapter {
  
  // Declare Variables
  Context context;
  LayoutInflater inflater;
  ArrayList&lt;HashMap&lt;String, String&gt;&gt; data;
  ImageLoader imageLoader;
  HashMap&lt;String, String&gt; resultp = new HashMap&lt;String, String&gt;();
  
  public ListViewAdapter(Context context,
          ArrayList&lt;HashMap&lt;String, String&gt;&gt; arraylist) {
      this.context = context;
      data = arraylist;
      imageLoader = new ImageLoader(context);
  }
  
  @Override
  public int getCount() {
      return data.size();
  }
  
  @Override
  public Object getItem(int position) {
      return null;
  }
  
  @Override
  public long getItemId(int position) {
      return 0;
  }
  
  public View getView(final int position, View convertView, ViewGroup parent) {
      // Declare Variables
      TextView country, rank;
      // TextView population;
      ImageView flag;
  
      inflater = (LayoutInflater) context
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
      View itemView = inflater.inflate(R.layout.listview_item, parent, false);
      // Get the position
      resultp = data.get(position);
  
      // Locate the TextViews in listview_item.xml
      rank = (TextView) itemView.findViewById(R.id.rank);
      country = (TextView) itemView.findViewById(R.id.country);
      // Locate the ImageView in listview_item.xml
      flag = (ImageView) itemView.findViewById(R.id.flag);
  
      // Capture position and set results to the TextViews
      distance.setText(resultp.get(FragmentPlaces.RANK));
      bar_name.setText(resultp.get(FragmentPlaces.COUNTRY));
      // population.setText(resultp.get(MainActivity.POPULATION));
      // Capture position and set results to the ImageView
      // Passes flag images URL into ImageLoader.class
      imageLoader.DisplayImage(resultp.get(FragmentPlaces.FLAG), logo_image);
      // Capture ListView item click
      itemView.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View arg0) {
              // // Get the position
              resultp = data.get(position);
  
              Bundle bundle = new Bundle();
              bundle.putString("rank", resultp.get(FragmentPlaces.RANK));
              bundle.putString("country",
                      resultp.get(FragmentPlaces.COUNTRY));
              bundle.putString("flag", resultp.get(FragmentPlaces.FLAG));
              // set Fragmentclass Arguments
              FragmentSubVenues fragSubVenues = new FragmentSubVenues();
              fragSubVenues.setArguments(bundle);
              // FragmentTransaction ft =
              // getFragmentManager().beginTransaction();
              // ft.replace(R.id.activity_main_content_fragment,
              // fragSubVenues);
              // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
              // ft.addToBackStack(null);
              // ft.commit();
              // FragmentManager fragmentManager =
              // activity.getFragmentManager();
  
          }
      });
      return itemView;
  }
  }
  </code></pre>
  
  <p>I want to navigate below Fragment:</p>
  
  <pre><code>  public FragmentSubVenues() {
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.fragment_subview, null);
      Bundle bundle = this.getArguments();
      if(bundle != null){
          bar_name = bundle.getString("country");
          bar_name = bundle.getString("rank");
          bar_name = bundle.getString("flag");
      }
  
      TextView txtrank = (TextView) view.findViewById(R.id.rank);
      TextView txtcountry = (TextView) view.findViewById(R.id.country);
      ImageView imgflag = (ImageView) view.findViewById(R.id.flag);
      txtrank.setText(country);
      txtcountry.setText(rank);
      imageLoader.DisplayImage(flag, imgflag);
  
      return view;
  }
  </code></pre>
  
  <p>}</p>