How do I get the currently displayed fragment?

前端 未结 30 2136
青春惊慌失措
青春惊慌失措 2020-11-22 11:21

I am playing with fragments in Android.

I know I can change a fragment by using the following code:

FragmentManager fragMgr = getSupportFragmentManag         


        
30条回答
  •  深忆病人
    2020-11-22 11:42

    It's a bit late, But for anyone who is interested : If you know the index of the your desired fragment in FragmentManager just get a reference to it and check for isMenuVisible() function! here :

    getSupportFragmentManager().getFragments().get(0).isMenuVisible()
    

    If true Its visible to user and so on!

提交回复
热议问题