I have worked in tab bar, using TabHost to develop the tab1, tab2 and tab3 in tab bar. When the app is launched, tab1 is visible by default on the main screen, then I select the tab2 screen, the tab2 screen have one button, when click these button to navigate another screen, that screen have a Listview and select the Listitem comes to the previous screen (tab1), but I want come to the screen in (tab2).
How do I fix this?
TabHost tabs=(TabHost)findViewById(R.id.tabhost);
tabs.setup();
TabHost.TabSpec spec=tabs.newTabSpec("tag1");
spec.setContent(R.id.tab1);
spec.setIndicator("A");
tabs.addTab(spec);
spec=tabs.newTabSpec("tag2");
spec.setContent(R.id.tab2);
spec.setIndicator("B");
tabs.addTab(spec);
spec=tabs.newTabSpec("tag3");
spec.setContent(R.id.tab3);
spec.setIndicator("C");
tabs.addTab(spec);
If you start a new activity, the state of the previous activity will not be used. You need to finish the list activity, so that you will go back the previous tab activity. So when you go back, the second tab will already be selected.