How to remove headers from BrowseFragment?
Asked Answered
C

4

9

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

Curtate answered 3/5, 2018 at 10:10 Comment(3)
You mean the header which are showing above rows ? Can you updates screen shot exactly ?Greyso
I want do delete the left side blue color, this side contains the headers of rowsCurtate
You mean whole left side part you need to remove ?Greyso
P
4

You have to set the HeaderState like this:

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHeadersState(HEADERS_DISABLED); // Add this line
}
Peptonize answered 3/5, 2018 at 15:6 Comment(6)
Thanks for your answers, but if i do that the rows disabled also ! I want do delete the left side blue color.Curtate
try HEADERS_HIDDENPeptonize
It works but the event between headers and rows still exist(the headers is hidden just one loaded)Curtate
Did you find a solution to thisShulins
@BillelBmsd, ebr answered worked for me. When I call setHeadersState(HEADERS_DISABLED); it disabled the headers and the rows were present. Weird, in the sample app google has provided they are calling in this onActivityCreated(), not sure if disabling worked for them.Psychogenesis
I am trying with both HEADERS_DISABLED and HEADERS_HIDDEN in OnActivityCreated() but the rows are also getting disabled.. can u give me a solution for thisPopgun
L
12

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);
}
Lupien answered 6/12, 2018 at 15:50 Comment(0)
P
4

You have to set the HeaderState like this:

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHeadersState(HEADERS_DISABLED); // Add this line
}
Peptonize answered 3/5, 2018 at 15:6 Comment(6)
Thanks for your answers, but if i do that the rows disabled also ! I want do delete the left side blue color.Curtate
try HEADERS_HIDDENPeptonize
It works but the event between headers and rows still exist(the headers is hidden just one loaded)Curtate
Did you find a solution to thisShulins
@BillelBmsd, ebr answered worked for me. When I call setHeadersState(HEADERS_DISABLED); it disabled the headers and the rows were present. Weird, in the sample app google has provided they are calling in this onActivityCreated(), not sure if disabling worked for them.Psychogenesis
I am trying with both HEADERS_DISABLED and HEADERS_HIDDEN in OnActivityCreated() but the rows are also getting disabled.. can u give me a solution for thisPopgun
M
1

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
Misplay answered 26/12, 2018 at 12:55 Comment(0)
S
1

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.

Stepdaughter answered 18/12, 2019 at 11:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.