gpt4 book ai didi

android - 如何从 tabactivity 启动的 Activity 更改 tabactivity 的选项卡?或更改当前选项卡

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:38:56 27 4
gpt4 key购买 nike

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();


}

如何从任何这些子 Activity (例如:诊断 Activity )更改当前选项卡...... ??

最佳答案

来自子 Activity :

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

关于android - 如何从 tabactivity 启动的 Activity 更改 tabactivity 的选项卡?或更改当前选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5460563/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com