Skip to content Skip to sidebar Skip to footer

Duplicate Menu And Data In Fragments After Using Fragmentstatepageradapter

I tried so many answers provided by various posts here but nothing worked for me. Problem- I have navigation drawer that has 6 fragments but single activity. Everything worked fine

Solution 1:

  private void hideAllMenuItems() {
        if (actionBarMenu != null) {
            actionBarMenu.findItem(R.id.action_item1).setVisible(false);
            actionBarMenu.findItem(R.id.action_item2).setVisible(false);
        }
    }


    private void showMenuIcon() {
        if (actionBarMenu != null) {
            hideAllMenuItems();
            if (currentFragment instanceof Fragment1)
                actionBarMenu.findItem(R.id.action_item1).setVisible(true);

            else if (currentFragment instanceof Fragment2)
                actionBarMenu.findItem(R.id.action_item2).setVisible(true);

        }
    }

call shoeMenuIcon() each time new fragment load..

Hope you are looking for this

Post a Comment for "Duplicate Menu And Data In Fragments After Using Fragmentstatepageradapter"