Answer the question
In order to leave comments, you need to log in
How to jump to a specific tab when startActivity android is called?
I have two lists of messages in the application, incoming and outgoing which are placed on two tabs, then when I select one of the messages, I go to the activity where the message is displayed. This activity has a toolbar at the bottom where the back button is located, but I can currently go to the first tab, but I need something like we opened a message from the inbox list and then when we return to the previous message list, go to the inbox list, and so - same to do with outgoing. Can somehow pass position to an activity that has a recyclerview and slidingtabs? I now have such a listener for the choice of tabs:
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
/*String position = String.valueOf(tab.getPosition());
Toast.makeText(SecondScreen.this,position,Toast.LENGTH_LONG).show();*/
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
viewPager.setCurrentItem(tab.getPosition());
Answer the question
In order to leave comments, you need to log in
when you call an activity with tabs from the screen with a message - pass the position to it via intent.putExtra("position", index);
and inside the activity - getIntent.getIntExtra("position", defIndex); And instead of defIndex - the index of the tab to open if nothing came (for example, when you get to the screen with tabs from other places)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question