开发者

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

开发者 https://www.devze.com 2023-02-20 02:27 出处:网络
public class HMITabActivity extends TabActivity{ @Override protected void onCreate(Bundle savedInstanceState) {
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();


    }
开发者_StackOverflow中文版

}

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


From the child activity:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号