androidandroid-tvleanback

Different viewtype in Leanback's VerticalGridView


I am trying to add different presenter in a vertical list in verticalGridView just like in recyclerview but I can't wrap my head around it. Can someone point me in the right direction ?


Solution

  • it looks like you should use PresenterSelector.

    it can change presenter types depends on data or class.

    You could find examples in google samples

    data - https://github.com/android/tv-samples/blob/6bb311ef631e8ebda0f201114853295cae751122/LeanbackShowcase/app/src/main/java/androidx/leanback/leanbackshowcase/cards/presenters/CardPresenterSelector.java

    class - https://developer.android.com/reference/androidx/leanback/widget/ClassPresenterSelector