title: How to provide back button in fragments programmatically?
body: <p>I have one Activity with two fragments.here i provide one back button in 2nd fragment programatically to goback to 1st fragment.</p>
  
  <p>here my fragment1 code:</p>
  
  <pre><code> public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
      Bundle savedInstanceState) {
      // Inflate the layout for this fragment
        V = inflater.inflate(R.layout.lm_fragement, container, false);
       listview = (ListView)V.findViewById(R.id.listView1);
       url="http://victorysites.org/apps/SSPC/homeinfo.php?UDID=12341234";
  
       JsonParsing json=new JsonParsing();
       list=json.getData(url);
       System.out.println("length :"+list.size());
  
       listview.setAdapter(new MyAdapter(getActivity(),list));
  
  
       final ProgressDialog waitdialog;
  
  
  
        listview.setOnItemClickListener(new OnItemClickListener() {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) {
              // TODO Auto-generated method stub
              Bundle data = new Bundle();
              data.putString("name",""+arg2);
              Fragment f;
              f = new PM_Fragment();
              f.setArguments(data);
              FragmentTransaction ft = getFragmentManager().beginTransaction();
              ft.replace(android.R.id.content, f);
              ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
              ft.addToBackStack(null);
              ft.commit(); 
          }
      });
  
      Button bt=(Button)V.findViewById(R.id.button1);
      bt.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              Bundle data = new Bundle();
              data.putString("name","Venkat");
              Fragment f;
              f = new PM_Fragment();
              f.setArguments(data);
              FragmentTransaction ft = getFragmentManager().beginTransaction();
              ft.replace(android.R.id.content, f);
              ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
              ft.addToBackStack(null);
              ft.commit();
          }
      });
  
  
      return V;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Here my fragment2 code:</p>
  
  <pre><code>  public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
      Bundle savedInstanceState) {
      // Inflate the layout for this fragment
      f=new PM_Fragment();
        V = inflater.inflate(R.layout.pm_fragment, container, false);
       Bundle bundle = this.getArguments();
        String myInt = bundle.getString("name");
        System.out.println("NAME"+myInt);
        TextView tv=(TextView)V.findViewById(R.id.portrait_message);
        tv.setText(myInt);
  
      Button bt=(Button)V.findViewById(R.id.button1);
      bt.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
  
              /*Fragment f=new PM_Fragment();
              getActivity().getSupportFragmentManager().beginTransaction().remove(f).commit();*/
              //getActivity().getFragmentManager().beginTransaction().remove(this).commit();
          getFragmentManager().popBackStack();
  
  
          }
      });
  
  
      return V;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>its working fine,but the problem is it reloads the previous(1st fragment) screen.But i don't want reload the page,i want its working like default back button in emulator.</p>
  
  <p>Anyone can give me an idea. Thanks in advance.</p>