4
public class HMITabActivity extends TabActivity{
 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final TabHost tabHost = getTabHost();
        tabHost.addTab(tabHost.newTabSpec("Tasks")
                .setIndicator("Tasks", getResources().getDrawable(R.drawable.program))
                .setContent(new Intent(this, Tasks.class)));

        tabHost.addTab(tabHost.newTabSpec("HMI")
                .setIndicator("HMI")
                .setContent(new Intent(this, HMI.class)));
        tabHost.addTab(tabHost.newTabSpec("Diagnostics")
                .setIndicator("Diagnostics", getResources().getDrawable(R.drawable.diagnostics))
                .setContent(new Intent(this, Diagnostics.class)));
        tabHost.addTab(tabHost.newTabSpec("About")
                .setIndicator("About")
                .setContent(new Intent(this, Tasks.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
        //WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        //Method[] wmMethods = wifiManager.getClass().getDeclaredMethods();


    }

}

how to change the current tab from any of these sub activities (eg: Diagnostics activity).... ??

Arun Abraham
  • 4,011
  • 14
  • 54
  • 75

1 Answers1

16

From the child activity:

((TabActivity) getParent()).getTabHost().setCurrentTab(2)
Yoni Samlan
  • 37,905
  • 5
  • 60
  • 62
  • I m using like this but its getting error. http://stackoverflow.com/questions/25281422/switching-tabs-from-child-activity?noredirect=1#comment39396764_25281422 – mehmetakifalp Aug 13 '14 at 08:35