title: MainActivity to Fragment and from that Fragment back to MainActivity
body: <p><a href="https://stackoverflow.com/questions/31283344/mainactivity-to-fragment-and-from-that-fragment-back-to-mainactivity/31284973#31284973">Solve by using getActivity()</a><br/>
  I have this MainActivity.java and RepeatEntry.java</p>
  
  <p>inside my MainActivity i have this code to have RepeatEntry ui</p>
  
  <pre><code>//i did hide two linear layout here with buttons and edittext inside it ,using the following method 
   hideTwoLinearLayout();
   showCategoryContainerLayout();
  Fragment fragment = new RepeatEntry();
   FragmentManager fm = getFragmentManager();
   FragmentTransaction ft = fm.beginTransaction();
    //category_cont is a linear layout container for my fragment
   ft.replace(R.id.category_cont, fragment);
   ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
   ft.commit();
  </code></pre>
  
  <p>inside my RepeatEntry.java sample code </p>
  
  <pre><code>Button k = (Button) v.findViewById(R.id.button);
          k.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                 // Intent intent = new Intent(getActivity(),MainActivity.class);
                 // startActivity(intent);
  
                 // if i use popBackStack and also remove the code for intent , i cannot show what i hide  
  //note i have a method inside mainactivity to showTwoLinearLayout()
                 getFragmentManager().popBackStack();
              }
          });
  </code></pre>
  
  <p>Now my question is, <strong>do i have other option other than using intent to go back to MainActivity view</strong> </p>
  
  <p><strong>Note:Edited</strong></p>