Billel Boumessaidia
Billel Boumessaidia

Reputation: 241

How to remove headers from BrowseFragment?

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

Upvotes: 9

Views: 3003

Answers (4)

Abdelkader Sellami
Abdelkader Sellami

Reputation: 61

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.

Upvotes: 1

Ranjith
Ranjith

Reputation: 41

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

Upvotes: 1

ebr
ebr

Reputation: 333

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);
}

Upvotes: 12

Sofiane Daoud
Sofiane Daoud

Reputation: 878

You have to set the HeaderState like this:

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

Upvotes: 4

Related Questions