我试图充气

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

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

膨胀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" />

它正在膨胀而没有任何错误,我能够在列表 View 中显示缩略图

我的要求是用户单击此缩略图视频时应在列表 View 中播放

请提出我该如何实现?

最佳答案

documentation:



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

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

关于android - 膨胀列表适配器中的类com.google.android.youtube.player.YouTubePlayerView时出错,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31570169/

10-12 05:09