Search code examples
androidandroid-fragmentstabsandroid-fragmentactivity

ANDROID Swipe-able Tabs


I've swipe-able tabs in one activity. When a user clicks on an EditText field to enter , I launch another activity to take the input and then I revert back to the tab activity. However, whenever I return to this activity with tabs, only the 1st tab is shown.

How do I display a different tab when I revert back to this activity after taking input from a different activity? Ideally, I'd want to return to the tab/fragment from which the intent was passed.

EDIT : FIXED

This piece of code helped me solve this issue.

int pos = bundle.getInt("pos");
TabLayout.Tab tab = tabLayout.getTabAt(pos);
tab.select();

Solution

  • This piece of code helped me resolve the issue.

     int pos = bundle.getInt("pos");
     TabLayout.Tab tab = tabLayout.getTabAt(pos);
     tab.select();