在列表适配器中为类com.google.android.youtube.player.YouTubePlayerView充气时出错
我想充气在列表适配器中为类com.google.android.youtube.player.YouTubePlayerView充气时出错,android,youtube-api,android-youtube-api,Android,Youtube Api,Android Youtube Api,我想充气 <com.google.android.youtube.player.YouTubePlayerView android:id="@+id/youtubeplayerview" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding=
<com.google.android.youtube.player.YouTubePlayerView
android:id="@+id/youtubeplayerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp" />
在列表适配器,以便我可以在listview中播放视频它自己,但我得到的错误
对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" />
它正在膨胀,没有任何错误,我能够在列表视图中显示缩略图
我的要求是当用户点击这个缩略图视频应该在列表视图中播放
请建议我如何实现这一点?来自:
直接使用此视图是使用
YouTubePlayerFragment
。如果选择直接使用此视图,则
活动需要扩展YouTubeBaseActivity
因此,您必须确保您的活动扩展了YouTubeBaseActivity。或者,如果您的活动不需要扩展库提供的活动,则可以使用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"/>
除了非机器人的答案之外,我想补充一点,您应该确保调用super.onCreate(Bundle)
方法,因为YouTubeBaseActivity
类似乎没有@CallSuper
注释。如果您不想在布局中使用片段,您可以使用的另一个解决方案是从YouTubeBaseActivity()
扩展活动。这将允许您在布局中使用
例如:
class PlayVideoActivity : YouTubeBaseActivity(), YouTubePlayer.OnInitializedListener {...}
在java文件中
MainActivity.java
尝试将公共类MainActivity Extendes AppCompatActivity
替换为公共类MainActivity Extendes YouTubeBaseAActivity
,但方法是设置支持操作栏(工具栏);给出错误,因为如果您的活动不是从AppCompatActivity扩展而来,则无法调用该错误。如果工具栏是必需的,该怎么办?@not_a_bot我的问题链接是:我仍然错误地膨胀类片段,还有其他错误二进制XML文件行#15:重复id 0x7f1001d0、标记null或父id 0x7f1001cf以及com.google.android.youtube.player.YouTubePlayerSupportFragment的另一个片段