How to remove headers from BrowseFragment?

2.9k Views Asked by At

I am working on an android TV app and I am using the leanback library.

I want to customize the app layout "BrowseFragment". I want to remove the header view and only display the card list "rows".

Is it possible to do that or is there any other solution to achieve that?

I want to remove that

4

There are 4 best solutions below

6
Sofiane Daoud On BEST ANSWER

You have to set the HeaderState like this:

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHeadersState(HEADERS_DISABLED); // Add this line
}
0
ebr On

The above call actually needs to be in the OnCreate method instead of OnActivityCreated.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHeadersState(HEADERS_DISABLED);
}
0
Ranjith On

There are two options:

/** The headers fragment is enabled and hidden by default. */

HEADERS_HIDDEN

/** The headers fragment is disabled and will never be shown. */

HEADERS_DISABLED

OnCreate, you have to set the Header:

    setHeadersState(HEADERS_DISABLED); //To Diable the Header

    setHeadersState(HEADERS_HIDDEN); //To Hide the Header
0
Abdelkader Sellami On

When you change the setHeaderState(HEADERS_DISABLED), the rows would be disabled and hidden too. One way to do it is setHeaderPresenterSelector()

private void setupUIElements() {

    setHeadersState(HEADERS_DISABLED);

    setHeaderPresenterSelector(new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object item) {
            return new CustomPresenter();
        }
    });
}

you just need to override the getPresenter() method, and return new customized presenter that you need to implement.