面对 TabActivity 的问题,我在可能的 tabActivity 中有 5 个标签到一个标签,我正在使用带有 ACTION_VIEW 的 Intent 播放 YouTube 视频。当我第一次选择该选项卡时,它会打开浏览器并播放我的视频,但下次它不会响应我。我尝试了很多。如果您有任何解决方案,请与我分享。
这是 TabActivit 的代码形式
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getWindow().setWindowAnimations(0);
tabHost = getTabHost();
tabHost.setup();
extras = getIntent().getExtras();
int isFetched = extras.getInt("IsFetched", 0);
Resources res = getResources();
Intent t0 = new Intent(this, HomeTabGroup.class);
t0.putExtra("IsFetched",isFetched);
tabHost.addTab(tabHost.newTabSpec("Home")
.setIndicator(prepareTabView(this, "0", res
.getDrawable(R.drawable.hometab)))
.setContent(t0));
tabHost.getTabWidget().setBackgroundResource(R.drawable.bg_nav);
// Intent t1 = new Intent(this, SurprizeMeTabGroup.class);
Intent t1 = new Intent(this, SurpriseScreen.class);
tabHost.addTab(tabHost.newTabSpec("surprise")
.setIndicator(prepareTabView(this, "1", res
.getDrawable(R.drawable.surprizetab)))
.setContent(t1));
tabHost.setCurrentTab(0);
HomeTabGroup.group.tabHost = this.tabHost;
以下是我的 SurpizeScreen 的代码
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.surprise_screen);
Intent intent = getYouTubeIntent(this, "http://www.youtube.com/watch?v=6KKXVbJCKEo");
startActivity(intent);
}