更改编程标签与SlidingTabLayout [英] Change Tab Programmatically with SlidingTabLayout

查看:141
本文介绍了更改编程标签与SlidingTabLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的<一个href="https://developer.android.com/samples/SlidingTabsBasic/src/com.example.android.common/view/SlidingTabLayout.html"相对=nofollow> SlidingTabLayout 通过谷歌提供的例子。我想以编程方式切换回第一个标签一个dial​​ogView这是一个片段内内。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆