<p>These classes teach you how to build apps for TV devices.</p>
<p class="note"><strong>Note:</strong> For details on how to publish your TV apps in Google Play, see <a href="{docRoot}distribute/googleplay/tv.html">Distributing to Android TV</a>.</p>
No newline at end of file
<p class="note"><strong>Note:</strong> For details on how to publish your TV
apps in Google Play, see <a href="{@docRoot}distribute/googleplay/tv.html">
and {@link android.support.v17.leanback.app.BrowseFragment#setHeadersTransitionOnBackEnabled(boolean) setHeadersTransitionOnBackEnabled()} hide or disable the headers. See
<a href="#hide-heads">Hide or Disable Headers</a> for more information.
public void onUnbindViewHolder(ViewHolder viewHolder) {
// no op
}
}
</pre>
<p>This example shows how to define the presenter for a complex layout with
multiple views, and you could use this pattern to do something even more complex.
However, an easier way to combine a {@link android.widget.TextView} with a
drawable resource is to use the <a href="{@docRoot}reference/android/widget/TextView.html#attr_android:drawableLeft">
{@code TextView.drawableLeft}</a> attribute. Doing it this way, you don't need the
{@link android.widget.ImageView} shown here.</p>
<p>In the {@link android.support.v17.leanback.app.BrowseFragment} implementation that displays the
catalog browser, use the {@link android.support.v17.leanback.app.BrowseFragment#setHeaderPresenterSelector(android.support.v17.leanback.widget.PresenterSelector) setHeaderPresenterSelector()}
method to set the presenter for the row header, as shown in the following example.</p>
<p>Sometimes you may not want the row headers to appear: when there aren't enough categories to
require a scrollable list, for example. Call the {@link android.support.v17.leanback.app.BrowseFragment#setHeadersState(int) BrowseFragment.setHeadersState()}
method during the fragment's {@link android.app.Fragment#onActivityCreated(android.os.Bundle) onActivityCreated()}
method to hide or disable the row headers. The {@link android.support.v17.leanback.app.BrowseFragment#setHeadersState(int) setHeadersState()}
method sets the initial state of the headers in the browse fragment given one of the following
constants as a parameter:</p>
<ul>
<li>{@link android.support.v17.leanback.app.BrowseFragment#HEADERS_ENABLED} - When the browse
fragment activity is created, the headers are enabled and shown by default. The headers appear as
shown in figures 1 and 2 on this page.</li>
<li>{@link android.support.v17.leanback.app.BrowseFragment#HEADERS_HIDDEN} - When the browse
fragment activity is created, headers are enabled and hidden by default. The header section of the
screen is collapsed, as shown in <a href="{@docRoot}training/tv/playback/card.html#collapsed">
figure 1</a> of <a href="{@docRoot}training/tv/playback/card.html">Providing a Card View</a>. The
user can select the collapsed header section to expand it.</li>
<li>{@link android.support.v17.leanback.app.BrowseFragment#HEADERS_DISABLED} - When the browse
fragment activity is created, headers are disabled by default and are never displayed.</li>
</ul>
<p>If either {@link android.support.v17.leanback.app.BrowseFragment#HEADERS_ENABLED} or
{@link android.support.v17.leanback.app.BrowseFragment#HEADERS_HIDDEN} is set, you can call
to support moving back to the row header from a selected content item in the row. This is enabled by
default (if you don't call the method), but if you want to handle the back movement yourself, you
should pass the value <code>false</code> to {@link android.support.v17.leanback.app.BrowseFragment#setHeadersTransitionOnBackEnabled(boolean) setHeadersTransitionOnBackEnabled()}
and implement your own back stack handling.</p>
<h2 id="lists">Display Media Lists</h2>
<p>
The {@link android.support.v17.leanback.app.BrowseFragment} allows you to define and display
browsable media content categories and media items from a media catalog using adapters and
presenters. Adapters enable you to connect to local or online data sources that contain your
media catalog information. Presenters hold data about media items and provide layout information
for displaying an item on screen.
The {@link android.support.v17.leanback.app.BrowseFragment} class allows you
to define and display browsable media content categories and media items from
a media catalog using adapters and presenters. Adapters enable you to connect
to local or online data sources that contain your media catalog information.
Adapters use presenters to create views and bind data to those views for
displaying an item on screen.
</p>
<p>
@@ -131,11 +342,12 @@ public class StringPresenter extends Presenter {
</pre>
<p>
Once you have constructed a presenter class for your media items, you can build and attach an
adapter to the {@link android.support.v17.leanback.app.BrowseFragment} to display those items on
screen for browsing by the user. The following example code demonstrates how to construct an
adapter to display categories and items in those categories using the {@code StringPresenter}
class shown in the previous code example:
Once you have constructed a presenter class for your media items, you can build
an adapter and attach it to the {@link android.support.v17.leanback.app.BrowseFragment}
to display those items on screen for browsing by the user. The following example
code demonstrates how to construct an adapter to display categories and items
in those categories using the {@code StringPresenter} class shown in the