是否可以将RowsSupportFragment的子类传递给BrowseSupportFragment的子类?

时间:2019-04-06 10:52:29

标签: kotlin android-tv leanback

我想传递BrowseSupportFragment子类的RowsSupportFragment的子类,因为我需要重写RowsSupportFragment中的某些方法以更改RowsSupportFragment的默认行为。

例如,要始终显示行标题,可以通过将setExpand()函数重写为true。

同一问题适用于HeadersSupportFragment的子类。

1 个答案:

答案 0 :(得分:1)

尚未测试过,但我认为它应该可以工作。

在您的BrowseSupportFragment中,为您的子类创建自定义FragmentFactory,并覆盖现有的ListRow对,如下所示:

getMainFragmentRegistry().registerFragment(ListRow.class, new FragmentFactory<CustomRowsSupportFragment>() {
            @Override
            public CustomRowsSupportFragment createFragment(Object row) {
                return new CustomRowsSupportFragment();
            }
       }
);
相关问题