Reputation: 241
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?
Upvotes: 9
Views: 3003
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
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
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
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