android - Android 上的刷新选项卡 Activity

标签 android android-intent refresh tabactivity android-tabactivity

单击 Tab Activity 返回后,我需要刷新我的 Activity 。目前它只显示以前的内容。我需要刷新我的 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);

}

最佳答案

这是最后添加的代码...我添加了 .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); 

谢谢大家

关于android - Android 上的刷新选项卡 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11109015/

相关文章:

Android - 使用 Robolectric 测试字符串资源

Android向后兼容性: reflection versus simple conditional check

android - 间接引用(别名)到android中的自定义xml属性

java - ActivityManager 为带按钮的 Android Widget 持续记录消息 "Launch Activity, postpone broadcast intents"

android - 使用 Intent 时 Activity 意外停止

javascript - 强大的自动刷新网页

android - BroadcastReceiver 多久监听一次 Intents

Android 视频 Intent : Control back button?

Android toggleButton.setOnText 和 .invalidate 不刷新文本

php - 如何将 setInterval 与 mouseenter 结合起来?