Android: How to recreate Action bar when fragment changed

后端 未结 4 1862
借酒劲吻你
借酒劲吻你 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:31

    Finally I couldn't find any sound way to achieve this.

    The best would be to make actionbar a part of fragment, not activity, but it's impossible.

    I end up with clearing actionbar menu and title when swipe begins(you can set special listener in PageView) and setting menu and title again when swipe complete and new fragment are shown.

    In gives some time lag and actionbar looks strangely empty during swipe, but it's best you can do.
    Android API is c...

提交回复
热议问题