As with almost all things with Leanback
, there's more than one way to skin the cat.
We needed to customize the ListRow
to add more padding to the header. We've achieved this level of customization by overriding onBindRowViewHolder
of ListRowPresenter
, grabbing the View
for the header (via View header = holder.getHeaderViewHolder().view;
). And then we changed the height of it with header.getLayoutParams().height = rowItem.getRowHeaderHeight();
.
With this same technique, you could dynamically add your footer view to holder.view
(with addView
).
Another approach would be following the what the documentation for RowPresenter
recommends. The relevant quote is:
When a subclass of RowPresenter adds UI widgets, it should subclass RowPresenter.ViewHolder and override createRowViewHolder(ViewGroup) and initializeRowViewHolder(ViewHolder). The subclass must use layout id "row_content" for the widget that will be aligned to the title of any HeadersFragment that may exist in the parent fragment.
So with this new recommended approach, you'll basically be supplying your own xml. I believe you can even subclass ListRowPresenter
. To see how the code works, look at ListRowView
to see that it inflates the xml for R.layout.lb_list_row
. And then it just uses the view for R.id.row_content
.
Then that'll be the actual view that's supplied by holder.view
and then you can set text on it and do whatever you want.
Let me know if you need any further clarification.