代码之家  ›  专栏  ›  技术社区  ›  daveomcd

如何重新加载选项卡中存在的活动?

  •  3
  • daveomcd  · 技术社区  · 14 年前

    我有一个带有3个选项卡的选项卡视图(每个选项卡都有自己的活动)。我有一个标签可以解析RSS提要。如何通过菜单按钮刷新此提要?我试着做了下面的事,但我失去了上面的标签当然。谢谢!

      Intent UpdateFeedIntent = new Intent(classA.this, classA.class);
    

    完成();

    2 回复  |  直到 14 年前
        2
  •  -1
  •   daveomcd    14 年前

    所以谢谢贾斯汀的链接。在尝试了许多不同的方法之后,我终于找到了工作(我们将尽可能地缩短它,但是为了减少混乱,我们将在实际代码中编写它。)

    ListAdapter adapter;
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(SavedInstanceState);
        rssparser();
        adapter = new MyCustomAdapter(this, R.layout.list_item, rsstitles);
        setListAdapter(adapter);
    }
    
    public void onResume() {
        super.onResume();
    
        rsstitles.clear();  // this line is what finally got the notifyDataSetChanged() to work
    
        rssparser();
        ((MyCustomAdapter) adapter).notifyDataSetChanged();
        setListAdapter(getListAdapter());
    }