Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Tab Programmatically with SlidingTabLayout

Tags:

android

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.

I see a scrollToTab(int tabIndex, int positionOffset). How can I call this to return to the first tab?

like image 250
ecirish Avatar asked Mar 27 '15 22:03

ecirish


1 Answers

You can use:

viewPager.setCurrentItem(itemIndex);

viewPager being your view pager for the tabs that you specified in the layout as

android.support.v4.view.ViewPager

like image 81
EZDsIt Avatar answered Nov 16 '22 13:11

EZDsIt