The code consists of a BrowseFragment that has multiple list rows associated to each header row, in reference to this code, i was able to implement it correctly using PageRow instead of ListRow (https://github.com/googlesamples/leanback-showcase/blob/master/app/src/main/java/android/support/v17/leanback/supportleanbackshowcase/app/page/PageAndListRowFragment.java)
The problem is with this function that helps me customize the headers (add icon to the headers:
browseFragment.setHeaderPresenterSelector(new PresenterSelector() {
@Override
public IconHeaderPresenter getPresenter(Object item) {
return new IconHeaderPresenter();
}
});
Once I add it, the headers are no longer selected, and I can't navigate between them.
This is how I am creating the browsefragment:
...
browseFragment = new BrowseFragment();
browseFragment.setHeadersState(BrowseFragment.HEADERS_ENABLED);
browseFragment.prepareEntranceTransition();
browseFragment.setHeaderPresenterSelector(new PresenterSelector() {
@Override
public IconHeaderPresenter getPresenter(Object item) {
return new IconHeaderPresenter();
}
});
mBackgroundManager = BackgroundManager.getInstance(shared.main);
mBackgroundManager.attach(shared.main.getWindow());
browseFragment.getMainFragmentRegistry().registerFragment(IconPageRow.class,
new PageRowFragmentFactory(mBackgroundManager));
...
private static class PageRowFragmentFactory extends BrowseFragment.FragmentFactory {
private final BackgroundManager mBackgroundManager;
PageRowFragmentFactory(BackgroundManager backgroundManager) {
this.mBackgroundManager = backgroundManager;
}
@Override
public Fragment createFragment(Object rowObj) {
ArrayObjectAdapter adapter=((IconPageRow)rowObj).getAdapter();
RowsFragment rowsFragment = new RowsFragment();
rowsFragment.enableRowScaling(true);
rowsFragment.setAdapter(adapter);
mBackgroundManager.setDrawable(null);
rowsFragment.setOnItemViewClickedListener(browseClickListener);
rowsFragment.setOnItemViewSelectedListener(browseSelectedListener);
return rowsFragment;
}
}
The solution to this was to add to my Custom Header presenter (IconHeaderPresenter) in onCreateViewHolder these two lines:
view.setFocusable(true);
view.setFocusableInTouchMode(true);