就像我说我有我的程序tabView,我想通过活动传递一些数据。当我尝试startActivity时,标签消失。所以我想要而不是尝试startActivity。我想更改选项卡。(android)更改选项卡,而不是startActivity
我有3个活动一个为每个选项卡和一个分开持有tabview。
public class Start extends TabActivity {
TabHost tabHost;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.start);
Resources res = getResources(); // Resource object to get Drawables
tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Reusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
intent = new Intent().setClass(this, Home.class);
spec = tabHost.newTabSpec("Home").setIndicator("Home",
res.getDrawable(R.drawable.ic_tab_main))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, History.class);
spec = tabHost.newTabSpec("History").setIndicator("History",
res.getDrawable(R.drawable.ic_tab_history))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, Settings.class);
spec = tabHost.newTabSpec("Settings").setIndicator("Settings",
res.getDrawable(R.drawable.ic_tab_settings))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
多数民众赞成我如何添加标签,我不知道如何更改从其他活动选项卡。我尝试这样做:
Start tab;
tab.tabHost.setCurrentTab(0);
,但我得到错误....:/
我真的不明白你想要做什么,请给我解释一下吗? –
请参阅:http://stackoverflow.com/questions/1306689/launching-activities-within-a-tab-in-android – Dyonisos
我总共有4项活动。 1拥有TabView(Start.java),每个标签另有3个活动。我想在活动之间传递一些数据,但是当我尝试startActivity时,我在屏幕上获得了活动,但所有选项卡都消失了。所以,而不是startactivity我只想改变选项卡,所以tas不会消失,我不知道如何改变选项卡programmaticaly –