title: How to open another fragment from inside a ViewPager fragment?
body: <p>I followed this tutorial to build an app with three fragments in sliding view (ViewPager).</p>
  <p><a href="https://c1ctech.com/android-viewpager-example-to-create-sliding-screens/" rel="nofollow noreferrer">https://c1ctech.com/android-viewpager-example-to-create-sliding-screens/</a></p>
  <p>The app was built successfully. Then I added a button inside FragmentOne. And also created another fragment named FragmentFour with fragment_four.xml layout file.</p>
  <p>Now I want to link the FragmentFour with FragmentOne through onClickListener with the button I created before. When in FragmentOne the button will be clicked, and it'll launch FragmentFour. To achive that, inside onClickListener I added these codes-</p>
  <pre><code>FragmentFour fragFour = new FragmentFour();
                      FragmentManager fragmentManager = getChildFragmentManager();
                      FragmentTransaction transaction = fragmentManager.beginTransaction();
                      transaction.replace(R.id.main_frameLayout, fragFour);
                      transaction.addToBackStack(null);
                      transaction.commit();
  </code></pre>
  <p>But after running the app, when I click on that button from inside the FragmentOne, FragmentFour's layout overlaps over the FragmentOne's layout. And FragmentTwo and FragmentThree can be accessible via sliding from FragmentFour, but I don't want this.</p>
  <p>If anything wrong here, please help me.</p>