Java 刷新tabHost中的Android选项卡
我有一个带有3个标签的tabHost,每个标签上都嵌入了youtube视频。每次单击选项卡时,它都会在选项卡视图中显示另一个视频,如下所示:Java 刷新tabHost中的Android选项卡,java,android,Java,Android,我有一个带有3个标签的tabHost,每个标签上都嵌入了youtube视频。每次单击选项卡时,它都会在选项卡视图中显示另一个视频,如下所示: TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost); TabSpec tab1 = tabHost.newTabSpec("Chilling"); TabSpec tab2 = tabHost.newTabSpec("Shit"); TabSpec tab3
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")) {
;}
按钮检查所选选项卡,我希望它刷新所选选项卡视图。我该怎么做
我知道tabHost已被弃用,但我的应用程序已基本就绪,我希望能这样完成:)
非常感谢您提前context.sendbroadcasting不起作用,我想在if语句中获取我的当前选项卡,并调用对选项卡1的刷新