You need to change the currently selected tab. There will be a method called setCurrentTabByTag(String tag) in the TabHost class that will do this, just pass the tag name of your tab (which in your case is B), or you can use setCurrentTab(int index) and pass the tab index.
Example. Usually I have a MainActivity class, which is my TabActivity. Inside this class, I will create all the tabs that I need in the onCreate method.
First, I set some static int with tab indices.
// Tab index. public static int FIRST_TAB = 0; public static int SECOND_TAB = 1;
Later I create my tabs in the onCreate method.
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
And the last method that will change the current tab.
public void switchTab(int index) { mTabHost.setCurrentTab(index); }
Later, inside MyFirstActivity, you can call the MainActivity swichTab method and pass the tab index to change it. You can get MainActivity by calling the getParent() method of the Activity class.
MainActivity parent = (MainActivity)getParent();
source share