简体   繁体   English

如何从tabactivity开始的活动中更改tabactivity的选项卡? 或更改当前选项卡

[英]how to change tab of a tabactivity from an activity started by the tabactivity ? or change current tab

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).... ?? 如何从任何这些子活动中更改当前选项卡(例如:诊断活动).... ??

从儿童活动:

((TabActivity) getParent()).getTabHost().setCurrentTab(2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM