在Android上刷新标签活动

dhi*_*iku 2 android refresh android-intent tabactivity android-tabactivity

单击我的Tab活动后,我需要刷新我的Activity.目前它只显示以前的内容.我需要刷新我的活动,因此可以在后面加载新内容.这是我添加TabActivity的代码.请帮忙.感谢您的所有反馈.

    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);

}
Run Code Online (Sandbox Code Playgroud)

dhi*_*iku 6

这是代码的最终添加...我添加了.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

TabHost tabHost = getTabHost();
Intent intent = new Intent(this, c).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId); 
Run Code Online (Sandbox Code Playgroud)

谢谢你们.