Android: How to recreate Action bar when fragment changed

后端 未结 4 1800
借酒劲吻你
借酒劲吻你 2021-01-31 09:54

I have an activity showing a few fragments. Activity view contains only ViewPager initialized with custom FragmentPagerAdapter. This adapter provide navigation among 3 fragments

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-31 10:37

    It can be done by implementing onCreateOptionsMenu and calling setHasOptionsMenu(true) in the onAttach callback in each fragment and change the actions accordingly.

    To show the fragment without any actions setHasOptionsMenu(false) in it

提交回复
热议问题