There is activity with TabHost and three TabHost :

  tabHost = getTabHost(); //tabHost.setup(); TabHost.TabSpec tabSpec; tabSpec = tabHost.newTabSpec("tag1"); tabSpec.setIndicator("Tab 1"); tabSpec.setContent(new Intent(this, Tab1Econom.class)); tabHost.addTab(tabSpec); tabSpec = tabHost.newTabSpec("tag2"); tabSpec.setIndicator("Tab 2"); tabSpec.setContent(new Intent(this, Tab2Normal.class)); tabHost.addTab(tabSpec); tabSpec = tabHost.newTabSpec("tag3"); tabSpec.setIndicator("Tab 3"); tabSpec.setContent(new Intent(this, Tab3Vip.class)); tabHost.addTab(tabSpec); tabHost.setCurrentTab(0);// таб по умолчанию при создании tabHost.setOnTabChangedListener(this); 

On tabs there are three TabActivity with input buttons for other activity . The problem is that when you exit the buttons, we return to the main activity with a tab by default. How can I make it return not on the Tab by default, but on the Tab on which the button was pressed.

    1 answer 1

    Create a variable int nomerTab ; In the interface, we process the click, and fill in the variable that we insert into the tab by default:

      tabHost = getTabHost(); TabHost.TabSpec tabSpec; tabSpec = tabHost.newTabSpec("tag1"); tabSpec.setIndicator("ЭКОНОМ"); tabSpec.setContent(new Intent(this, Tab1Econom.class)); tabHost.addTab(tabSpec); tabSpec = tabHost.newTabSpec("tag2"); tabSpec.setIndicator("НОРМА"); tabSpec.setContent(new Intent(this, Tab2Normal.class)); tabHost.addTab(tabSpec); tabSpec = tabHost.newTabSpec("tag3"); tabSpec.setIndicator("VIP"); tabSpec.setContent(new Intent(this, Tab3Vip.class)); tabHost.addTab(tabSpec); tabHost.setCurrentTab(nomerTab);// таб по умолчанию при создании tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String tag) { if (tag.equals("tag1")) { nomerTab = 0; } if (tag.equals("tag2")) { nomerTab = 1; } if (tag.equals("tag3")) { nomerTab = 2; } } });