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 时出错
基础教程推荐
- 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
- iOS - UINavigationController 添加多个正确的项目? 2022-01-01
- 如何将图像从一项活动发送到另一项活动? 2022-01-01
- 如何比较两个 NSDate:哪个是最近的? 2022-01-01
- Android Volley - 如何动画图像加载? 2022-01-01
- navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
- Play 商店的设备兼容性问题 2022-01-01
- UIImage 在开始时不适合 UIScrollView 2022-01-01
- SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
