Start Activity in TabActivity1 from TabActivity2
So in my application I'm using two different Tabhosts.Here is an example
TABHOST1 Contains :
TAB1 | TAB2 | TAB3 | TAB4 | TAB5
TABHOST2 Contanins :
TB1 | TB2 | TB3 | TB4 | TB5
TAB2 - Activity 1
TB2 - Activity 2
So basically I want to start Activity 2, using Activity 1.开发者_如何学GoThe both activities are in different TABHOSTS so I need to keep the TABHOST2 when I start Activity 2,from Activity 1 (which is in TABHOST1).
Any suggestions how can I do that? Thanks in advance!
Pass the selected tab index from Activity1
While starting Activity2
from Activity1
Intent in = new Intent(this, TABHOSTS2.class); //TABHOSTS2 or whatever your second TabActivity is.
in.putExtra("SelectedTab", 1);
startActivity(in);
and in you TABHOSTS2
which will be TabActivity
, do something like:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tabs);
//set you Tabs and blah blah
int selectedTab = getIntent().getIntExtra("SelectedTab", 0);
tabHost.setCurrentTab(selectedTab);
}
to start activity2 all you need to do is startActivity , no need for tabhost 2 . if your problem is how to keep child activity ( activity 2 in your case ) inside tabhost , go through ActivityGroup doc ,which will guide you about nested activities inside tabHost
精彩评论