Developer Console

Step 5: Provide the Details of the App Content Through the DetailsFragment (Fire TV)

Learn how to provide information about a specific piece of content. To do this, we'll use one of the main components of a Leanback-enabled project: the DetailsFragment.

The DetailsFragment

The DetailsFragment is displayed when the user selects a specific piece of content on the BrowseFragment. It contains information like title, subtitle, and description, and is accompanied by a preview of the content.

One of the most important classes used in the DetailsFragment is DetailsOverViewRow. This class defines which content is displayed in the fragment and, most importantly, is responsible for defining the actions that we can prompt our user to perform.

private void setupDetailsOverviewRow() {

    final DetailsOverviewRow row
			= new DetailsOverviewRow(mSelectedMovie);
    ...
    row.setImageDrawable(R.drawable.default_background));
    row.addAction(new Action(ACTION_WATCH_TRAILER,
				"Watch Trailer", "FREE")));

    mAdapter.add(row);
}

The highlighted row below highlights how easy it is to add a specific action to the DetailsFragment. Just by coding addAction(), we can add a new action for the user to perform. In this case, we added the unique ID ACTION_WATCH_TRAILER, for the action and two strings, Watch Trailer and FREE, to define the text field of the button.

Once we have added this line, the action will be displayed on the DetailsFragment.

By using actions, we can easily add IAP items like "Rent the Content," "Buy," or "Subscribe;" it's just a matter of attaching a Listener to the actions to perform consequent tasks.

When we deploy a Leanback-enabled project, the only action that is defined by default is "Watch Trailer," which prompts the trailer of the content to play.

Next Steps

Continue on to the last step: Step 6: Play Video Content with the PlaybackOverlayFragment .


Last updated: Oct 29, 2020