【问题标题】:Can't refresh data in BrowseFragment无法刷新 BrowseFragment 中的数据
【发布时间】:2017-12-11 15:42:30
【问题描述】:

我正在使用 this BrowseFragment(Leanback Showcase 中的 PageAndListRowFragment)为我的 android TV 应用中的每个标题项添加多行。现在我无法刷新此片段中的数据。一切正常。我将提供一个示例,我如何设置数据以及如何尝试刷新数据。 这是我的onCreate

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setupUi();
    loadData();
    mBackgroundManager = BackgroundManager.getInstance(getActivity());
    mBackgroundManager.attach(getActivity().getWindow());
    getMainFragmentRegistry().registerFragment(PageRow.class, new PageRowFragmentFactory(mBackgroundManager, myObject));
}

我已将myObject 传递到 PageRowFragmentFactory,这就是我将数据传递到我的片段中的方式。当我刷新数据时(我在 onCreate 中用不同的数据做同样的事情)

getMainFragmentRegistry().registerFragment(PageRow.class,new PageRowFragmentFactory(mBackgroundManager,myObject));

数据从未刷新,重要的是 PageRowFragmentFactory 中的createFragment() 方法没有调用(不是第一次刷新时)。可能是什么问题?

【问题讨论】:

    标签: android android-fragments leanback browsefragment


    【解决方案1】:

    只需传递您在片段工厂中使用的片段中的数据。您并不总是需要将数据作为参数传递。我建议您使用 setter 然后检查是否创建了片段,然后通知数据集更改。

    【讨论】:

      猜你喜欢
      • 2017-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多