Skip to content

Instantly share code, notes, and snippets.

@fnk0
Created October 11, 2016 23:26
Show Gist options
  • Save fnk0/b81ec47efa12cb4484853a7b166e7cec to your computer and use it in GitHub Desktop.
Save fnk0/b81ec47efa12cb4484853a7b166e7cec to your computer and use it in GitHub Desktop.
Create Rows
/**
* Creates the rows and sets up the adapter of the fragment
*/
private void createRows() {
// Creates the RowsAdapter for the Fragment
// The ListRowPresenter tells to render ListRow objects
ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
for (int i = 0; i < mRows.size(); i++) {
MovieRow row = mRows.get(i);
// Adds a new ListRow to the adapter. Each row will contain a collection of Movies
// That will be rendered using the MoviePresenter
HeaderItem headerItem = new HeaderItem(row.getId(), row.getTitle());
ListRow listRow = new ListRow(headerItem, row.getAdapter());
rowsAdapter.add(listRow);
}
// Sets this fragments Adapter.
// The setAdapter method is defined in the BrowseFragment of the Leanback Library
setAdapter(rowsAdapter);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment