更改编程标签与SlidingTabLayout [英] Change Tab Programmatically with SlidingTabLayout
问题描述
我使用的<一个href="https://developer.android.com/samples/SlidingTabsBasic/src/com.example.android.common/view/SlidingTabLayout.html"相对=nofollow> SlidingTabLayout 通过谷歌提供的例子。我想以编程方式切换回第一个标签一个dialogView这是一个片段内内。
I'm using the SlidingTabLayout example provided by Google. I'm trying to programmatically switch back to the first tab inside a dialogView that is inside a fragment.
我看到一个scrollToTab(INT的tabIndex,诠释positionOffset)。我怎样才能把这个返回到第一个选项卡?
I see a scrollToTab(int tabIndex, int positionOffset). How can I call this to return to the first tab?
推荐答案
您可以使用:
viewPager.setCurrentItem(itemIndex);
viewPager是你的看法寻呼机您在布局
viewPager being your view pager for the tabs that you specified in the layout as
android.support.v4.view.ViewPager
这篇关于更改编程标签与SlidingTabLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!