在列表适配器中膨胀类 com.google.android.youtube.player.YouTubePlayerView 时出错 [英] Error inflating class com.google.android.youtube.player.YouTubePlayerView In List Adapter

查看:20
本文介绍了在列表适配器中膨胀类 com.google.android.youtube.player.YouTubePlayerView 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试充气

<com.google.android.youtube.player.YouTubePlayerView
                android:id="@+id/youtubeplayerview"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="5dp" />

在列表适配器中,以便我可以在列表视图中自行播放视频,但出现错误

in List adapter so that I can play video in the listview it self but I am getting error

膨胀类 com.google.android.youtube.player.YouTubePlayerView 时出错

如果我正在使用

<com.google.android.youtube.player.YouTubeThumbnailView
                android:id="@+id/youtubeplayerview"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="5dp" />

它正在膨胀而没有任何错误,我可以在列表视图中显示缩略图

It is getting inflated without any error and I am able to display thumbnail in list view

我的要求是当用户点击这个缩略图视频时应该在列表视图中播放

My requirement is when user click on this thumbnail video should play in list view

请建议我怎样才能做到这一点?

Please suggest how can I achieve this ?

推荐答案

来自 文档:

直接使用此视图是使用YouTubePlayerFragment.如果您选择直接使用此视图,您的活动需要扩展 YouTubeBaseActivity.

Using this View directly is an alternative to using the YouTubePlayerFragment. If you choose to use this view directly, your activity needs to extend YouTubeBaseActivity.

因此,您必须确保您的活动扩展了 YouTubeBaseActivity.或者,如果您的 Activity 不需要扩展库提供的 Activity,您可以使用 android.support.v4 中的 YouTubePlayerSupportFragment 和 FrameActivity.

Therefore, you must make sure your activity extends YouTubeBaseActivity. Alternatively, if your activity does not need to extend an activity provided by the library, you can use the YouTubePlayerSupportFragment and FrameActivity from android.support.v4.

<fragment
  android:name="com.google.android.youtube.player.YouTubePlayerSupportFragment"
  android:id="@+id/youtubesupportfragment"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"/>

这篇关于在列表适配器中膨胀类 com.google.android.youtube.player.YouTubePlayerView 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆