diff options
author | Tim Kilbourn <tkilbourn@google.com> | 2014-04-05 23:42:58 -0700 |
---|---|---|
committer | Tim Kilbourn <tkilbourn@google.com> | 2014-04-09 00:45:00 -0700 |
commit | e0cd23d9d8dc95c502198a3f1d73e950d6b9ecd4 (patch) | |
tree | b76ea66ed6104f3908754fb7c400d6a6ca3a40bd /samples/SupportLeanbackDemos/src/com/example/android/leanback/CardPresenter.java | |
parent | 3d2e6fb9687438adce494692feec57b7b34a2109 (diff) | |
download | android_development-e0cd23d9d8dc95c502198a3f1d73e950d6b9ecd4.tar.gz android_development-e0cd23d9d8dc95c502198a3f1d73e950d6b9ecd4.tar.bz2 android_development-e0cd23d9d8dc95c502198a3f1d73e950d6b9ecd4.zip |
Use ImageCardview in leanback samples.
Change-Id: I14606ff001cfd4ce244f32a8f1c973847ac1d0e3
Diffstat (limited to 'samples/SupportLeanbackDemos/src/com/example/android/leanback/CardPresenter.java')
-rw-r--r-- | samples/SupportLeanbackDemos/src/com/example/android/leanback/CardPresenter.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/CardPresenter.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/CardPresenter.java new file mode 100644 index 000000000..502c77aea --- /dev/null +++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/CardPresenter.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.example.android.leanback; + +import android.support.v17.leanback.widget.ImageCardView; +import android.support.v17.leanback.widget.Presenter; +import android.util.Log; +import android.view.ViewGroup; +import android.widget.TextView; + +public class CardPresenter extends Presenter { + private static final String TAG = "CardPresenter"; + + public ViewHolder onCreateViewHolder(ViewGroup parent) { + Log.d(TAG, "onCreateViewHolder"); + ImageCardView v = new ImageCardView(parent.getContext()); + v.setFocusable(true); + v.setFocusableInTouchMode(true); + v.setMainImage( + parent.getContext().getResources().getDrawable(R.drawable.text_bg)); + return new ViewHolder(v); + } + + public void onBindViewHolder(ViewHolder viewHolder, Object item) { + Log.d(TAG, "onBindViewHolder for " + item.toString()); + ((ImageCardView) viewHolder.view).setTitleText(item.toString()); + } + + public void onUnbindViewHolder(ViewHolder viewHolder) { + Log.d(TAG, "onUnbindViewHolder"); + } +} |