我有一个带有3个标签的tabHost,每个标签都嵌入了一个youtube视频。每次我点击一个标签时,它会在标签视图中提供另一个视频:
TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
TabSpec tab1 = tabHost.newTabSpec("Chilling");
TabSpec tab2 = tabHost.newTabSpec("Shit");
TabSpec tab3 = tabHost.newTabSpec("Gaming");
tab1.setIndicator("Chilling");
tab1.setContent(new Intent(this, ChillScreen.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
tab2.setIndicator("Shit");
tab2.setContent(new Intent(this, SadScreen.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
tab3.setIndicator("Gaming");
tab3.setContent(new Intent(this, GamingScreen.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
/** Add the tabs to the TabHost to display. */
tabHost.addTab(tab1);
tabHost.addTab(tab2);
tabHost.addTab(tab3);
现在在创建这些标签的活动中,我有一个按钮,我希望它刷新选定的标签,我这样做:
Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String current_tab = tabHost.getCurrentTabTag();
if (current_tab.contains("Chilling")) {
;}
按钮检查所选的选项卡,我希望它刷新所选的tabView。我怎么能这样做?
我知道tabHost已被弃用,但我的应用程序已经准备好了,我希望像这样完成它:)
非常感谢你