nadine87
nadine87

Reputation: 530

Android Leanback library BrowseFragment

I want to use a BrowseFragment inside an activity along with another fragment. The purpose of the other fragment is to have a listview, on each selected item the BrowseFragment will be reloaded with new data. Is this recommended?

Upvotes: 2

Views: 486

Answers (1)

Kyle Venn
Kyle Venn

Reputation: 8038

Well the HeadersFragment in the BrowseFragment acts a lot like a ListView (since it's backed by a VerticalGridView which is backed by a RecyclerView) which lets you map your selections in the HeadersFragment to the fragments controlled by your BrowseFragment.

I cover the below in more depth in this post, but here is the gist:

With version 24.0.0 of the Leanback library, you can map a single HeaderItem (in the HeadersFragment) to multiple ListRows by using the PageRowFragmentFactory. If you map the HeaderItem to a RowsFragment (or any type of fragment for that matter) and populate that RowsFragment with multiple rows, then it sounds like it might be able to achieve what you described in your OP.

The BrowseFragment will handle all of the refreshing for you. So all you have to do is tell it what list item in the headers section maps to which fragment and it'll swap the fragments out for you. You should really clone the leanback showcase example app and play around with it in an emulator to see if it's what you're looking for.

Upvotes: 1

Related Questions