kamilp
kamilp

Reputation: 238

Is it possible to pass sub-class of RowsSupportFragment to sub-class of BrowseSupportFragment?

I want to pass a sub-class of RowsSupportFragment of sub-class of BrowseSupportFragment, because I need to override some methods in RowsSupportFragment to change default behavior of RowsSupportFragment.

For example, to always show rows headers, by overriding setExpand() function to true.

The same question applies to sub-class of HeadersSupportFragment.

Upvotes: 0

Views: 543

Answers (1)

Breiby
Breiby

Reputation: 552

Have not tested this, but I believe it should work.

In your BrowseSupportFragment, create a custom FragmentFactory for your sub-class and override the existing ListRow-pairing like this:

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

Upvotes: 2

Related Questions