在列表适配器中膨胀类 com.google.android.youtube.player.YouTubePlayerView 时出错

Error inflating class com.google.android.youtube.player.YouTubePlayerView In List Adapter(在列表适配器中膨胀类 com.google.android.youtube.player.YouTubePlayerView 时出错)
本文介绍了在列表适配器中膨胀类 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 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)