title: How to close the current fragment by using Button like the back button?
body: <p>I have try to close the current fragment by using Imagebutton.</p>
  
  <p>I am in Fragment-A and it will turn to the Fragment-B when I click the button.</p>
  
  <p>And when I click the button at Fragment-B , it will turn to the Fragment-C and close the Fragment-B.</p>
  
  <p>If I click the back button at Fragment-C , it will back to the Fragment-A.</p>
  
  <p>The code I have try is like the following </p>
  
  <pre><code>camera_album = (ImageButton) view.findViewById(R.id.camera_album);
  
  camera_album.setOnClickListener(new Button.OnClickListener() {
      @Override
      public void onClick(View v) {
  
                      closefragment();
          Fragment fragment = FileBrowserFragment.newInstance(null, null, null) ;
          MainActivity.addFragment(LocalFileBrowserFragment.this, fragment) ;
  
  
      }
  });
  
  private void closefragment() {
      getActivity().getFragmentManager().beginTransaction().remove(this).commit();
  }
  </code></pre>
  
  <p>When I click the back button at fragment-B , it turn to the Fragment-C. </p>
  
  <p>But when I click the back button on Fragment-C , it doesn't back to the Fragment-A.
  It back to the empty background. If I want to back to Fragment-A , I have to click the back button once again.</p>
  
  <p>SO , it seem doesn't close the current fragment complete.</p>
  
  <p>How to finish the current fragment like the back button of Android ?</p>