Why has TabListener been deprecated?

前端 未结 3 897
孤城傲影
孤城傲影 2021-01-04 21:42

In Android 5 (API level 21) the ActionBar.TabListener has been deprecated. Why? What are we supposed to use instead? Does this mean that action tabs as a UI element have bee

相关标签:
3条回答
  • 2021-01-04 22:02

    As of Android 5.0 a tab style layout is best created by using the newly introduced design library by google. The easiest way to implement it (and not having to rewrite everything) is by using TabLayout in conjunction with a ViewPager.

    I was able to reuse most of my code and it took me approx. 30 minutes to go through everything until I had a working TabLayout displaying my existing fragments.

    You can find a very good tutorial here: https://github.com/codepath/android_guides/wiki/Google-Play-Style-Tabs-using-TabLayout

    If you want more info on the design library this is a pretty good summary imo: https://github.com/codepath/android_guides/wiki/Design-Support-Library

    0 讨论(0)
  • 2021-01-04 22:03

    Look this example SlidingTabsBasics If you need more info - check Google I/O sources

    0 讨论(0)
  • 2021-01-04 22:04

    Several ActionBar-related classes have been deprecated in favor of Toolbar, which is a generalization of ActionBar. Some extra reading here.

    0 讨论(0)
提交回复
热议问题