How do I get the currently displayed fragment?

前端 未结 30 2195
青春惊慌失措
青春惊慌失措 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:25

    getSupportFragmentManager().findFragmentById(R.id.content_frame).getClass().getSimpleName();
    

    Well, I guess this is the most straight forward answer to this question. I hope this helps.

提交回复
热议问题