简体   繁体   English

无法刷新BrowseFragment中的数据

[英]Can't refresh data in BrowseFragment

I'm using this BrowseFragment ( PageAndListRowFragment in Leanback Showcase ) to add multiple rows for each header item in my android TV app. 我正在使用这个 BrowseFragment( Leanback Showcase中的PageAndListRowFragment )为我的Android TV应用程序中的每个标题项添加多行。 now I can't refresh data in this fragment.Everything is working properly. 现在我无法刷新此片段中的数据。一切工作正常。 I'll provide an example how I set the data and how I tried to refresh the data. 我将提供一个示例,说明如何设置数据以及如何尝试刷新数据。 this is my onCreate 这是我的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));
}

I've passed myObject into PageRowFragmentFactory, That's how i pass data into my fragments. 我已经将myObject传递给PageRowFragmentFactory,这就是我将数据传递给片段的方式。 When I refresh the data (I do the same thing in onCreate with different data) 当我刷新数据时(我在onCreate中使用不同的数据执行相同的操作)

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

data never refreshed, and the important thing is createFragment() method in PageRowFragmentFactory is not calling (when refresh not first time). 数据永不刷新,重要的是createFragment()方法未调用(当第一次刷新时)。 What could be the issue? 可能是什么问题?

just pass the datas in the fragment you use in fragment factory. 只需在片段工厂中使用的片段中传递数据即可。 You dont always need to pass the datas as arguments.I suggest you to use setters then check if fragment is created then notify dataset changes. 您不必总是将数据作为参数传递。我建议您使用setter,然后检查是否创建了片段,然后通知数据集更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM