Viewpager pages are not remain as such even if popstacking/backpressed

I have a fragment with ViewPager.The ViewPager contain 2 fragments(A and B).Fragment A contain an expandable list view.When I clicked an item in expandable list,it will got to another fragment.When I click back,it will popstack and show the the viewpager fragment.It works fine.But my problem is,when it is popstacked,the viewpager is reloading and it shows like the first time.I want to remain the expandable list view open as it is clicked when popstacked.I have spent lot of time on this.Can any one help me?

ReadingFragment ie.the main fragment

public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View mFragmentView = inflater.inflate(R.layout.fragment_reading, container, false);
    return mFragmentView;


public void onAttach(Activity activity) {
    adapter = new ReadingPagerAdapter(getChildFragmentManager()); //here used child fragment manager


public Fragment getItem(int position) {
    switch (position) {
        case 0:

            FragmentA tab1 =  FragmentA .newInstance("A");

        return tab1;
        case 1:

            FragmentB tab2 =  FragmentB.newInstance("B");

            return tab2;

            return null;


private void ChangeFragment(BaseFragment fragment, String title, boolean isReplace) {
  //  mTitleTextView.setText(title);
    this.fragment = fragment;
    mFragmentManager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
    fragmentTransaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out, android.R.animator.fade_in, android.R.animator.fade_out);

    if (isReplace) {
        fragmentTransaction.replace(, fragment, CURRENT_TAG);
    } else {
        fragmentTransaction.add(, fragment, CURRENT_TAG);

this is how I am changing the fragments

Archive from:


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *