将 ViewPager 与导航选项卡相关联
Associating ViewPager with navigation tabs
有什么方法可以将 ViewPager 中的每个片段与某个导航选项卡相关联吗?所以当我们翻转 right/left 时,右侧的选项卡将高亮显示。
谢谢。
使用 Material 设计支持库中的 TabLayout。
参见blog post中介绍库的"Tabs"段:
However, if you are using a ViewPager for horizontal paging between
tabs, you can create tabs directly from your PagerAdapter’s
getPageTitle() and then connect the two together using
setupWithViewPager(). This ensures that tab selection events update
the ViewPager and page changes update the selected tab.
有什么方法可以将 ViewPager 中的每个片段与某个导航选项卡相关联吗?所以当我们翻转 right/left 时,右侧的选项卡将高亮显示。
谢谢。
使用 Material 设计支持库中的 TabLayout。
参见blog post中介绍库的"Tabs"段:
However, if you are using a ViewPager for horizontal paging between tabs, you can create tabs directly from your PagerAdapter’s getPageTitle() and then connect the two together using setupWithViewPager(). This ensures that tab selection events update the ViewPager and page changes update the selected tab.