Error inflating class com.google.android.youtube.player.YouTubePlayerView In List Adapter(在列表适配器中膨胀类 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 extendYouTubeBaseActivity.
因此,您必须确保您的活动扩展了 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 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在列表适配器中膨胀类 com.google.android.youtube.player.YouTubePlayerView 时出错
基础教程推荐
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
