使用Google SlidingTabLayout如何以编程方式更改所选标签?
答案 0 :(得分:1)
@Bind(R.id.pager) ViewPager mViewPager;
@Bind(R.id.tabs) SlidingTabLayout tabs;
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_team_details);
ButterKnife.bind(this);
//get this value from savedInstanceState
int tabThatNeedsToBeSelected = 3;
myFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager(),params);
mViewPager.setAdapter(myFragmentPagerAdapter);
tabs.setViewPager(mViewPager);
mViewPager.setCurrentItem(tabThatNeedsToBeSelected);
}