Search code examples
javaandroidandroid-fragmentstabsandroid-tabbed-activity

Android Studio Tabbed Activity (Swipe Views) View Pager Check if Tabbed


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.


Solution

  • 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
            }
        }
    }