I've the following situation:
- Linear Layout
- ToolBar
- SlidingTabLayout
- ViewPager
- FrameLayout
Initially, I only add a fragment to the FrameLayout, and all works. Next I remove this fragment, create new Adapter, and bind adapter to the SlidingTabLayout. All works again, but now I need to set tab visibility to false, and I do this with
slidingTabLayout.setVisibility(View.GONE);
but I also need to replace the current view with a new fragment. Usually I do this with:
getFragmentManager().replace(parent, newFragment);
but now I can't do this because getFragmentManager().replace(ViewPager, newFragment); doesn't works. So how can I do this? And if is possible, can I add the ViewPager replacing in the backstack?
I find a solution. I made the following update to my layout:
So when I need to hide all the tabs and the ViewPager, in order to inflate a new Fragment in the Frame Layout, I do the following:
In the onBackPressed of this new fragment: