How do I select a Tab from a TabLayout? [closed]

1

I'm using a ViewPager, but I tried trying to select it and I could not do it correctly. By default I select the first tab but I need the tab selected by default to be the second one.

Also, when I enter another activity and then press back, it returns to the default tab. Is there a way to save the selected tab when I go to the other activity and when I return I can select the tab I previously saved?

    
asked by Juan Baquedano 08.01.2017 в 02:57
source

1 answer

1

If you do not use a ViewPager , you can select a tab with

// seleccionar primer tab
tabLayout.getTabAt(0).select();

// cambiar a quinto tab
tabLayout.getTabAt(4).select();
    
answered by 08.01.2017 / 03:51
source