我需要刷新我的活动,一旦我点击我的标签活动回来。目前它只是显示以前的内容。我需要刷新我的活动,所以新内容可以在其后面加载。这是我添加TabActivity的代码。请帮忙。感谢您的反馈。在Android上刷新标签活动
private void setTabs()
{
addTab("Home", R.drawable.tab_home, OptionsActivity.class);
addTab("News", R.drawable.tab_search, JsonActivity.class);
addTab("Scores", R.drawable.tab_home, scores.class);
addTab("Video", R.drawable.tab_search, JsonActivity2.class);
addTab("Follow Us", R.drawable.tab_home, SAXParserActivity.class);
addTab("Socket", R.drawable.tab_search, socketAndroid.class);
}
private void addTab(String labelId, int drawableId, Class<?> c)
{
TabHost tabHost = getTabHost();
Intent intent = new Intent(this, c);
TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);
View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
TextView title = (TextView) tabIndicator.findViewById(R.id.title);
title.setText(labelId);
ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
icon.setImageResource(drawableId);
spec.setIndicator(tabIndicator);
spec.setContent(intent);
tabHost.addTab(spec);
}
尽管我会添加这样的内容:“如果已设置,并且正在启动的活动已在当前任务中运行,则不会启动该活动的新实例,而是关闭其上的所有其他活动,并且此Intent将作为新的Intent传递给(现在处于顶端)旧活动。“ - http://developer.android.com/reference/android/content/Intent.html – else