0

I made a new Project in Android Studio with a Tabbed Activity which have the Navigation Style Swipe Views (View Pager). How can I now find out which Fragment is active and if the user has tabbed? Is there any way to check that?

So I made no changes with the Code I just want to check it.

Theroth
  • 31
  • 9
  • Possible duplicate of [How to get the selected Tab of a viewPager?](https://stackoverflow.com/questions/24909452/how-to-get-the-selected-tab-of-a-viewpager) – Pratik Popat Jul 17 '17 at 11:08

1 Answers1

0

Override setMenuVisibility method in fragment to check if it is visible or not

@Override
public void setMenuVisibility(boolean visible) {
    super.setMenuVisibility(visible);
    if (visible) {
          //do something
        }
    }
}
Ayush Khare
  • 1,802
  • 1
  • 15
  • 26
  • Thank you very much it worked correctly. Before I make another question, is there any way to check what Fragment is active too? So Fragment one, or what ever? – Theroth Jul 17 '17 at 14:02
  • OK solved. In the upper method you can do : this.getArguments().get("section_number") than you get the right fragment id – Theroth Jul 17 '17 at 15:58