Android - 如何添加到ViewFlipper 2个不同的布局s.t每个都有一个YouTubePlayerView?

时间:2016-04-30 21:50:34

标签: android youtube-api embedded viewflipper

是否可以将一个YouTubePlayerView添加到ViewFlipper 2不同的布局? 我尝试做类似我添加的代码,但播放器崩溃。在ViewFlipper显示下一个视图后,有没有办法再次初始化播放器?

 <ViewFlipper
    android:id="@+id/view_flipper"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <RelativeLayout
        android:id="@+id/video_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="vertical">

        <com.google.android.youtube.player.YouTubePlayerView
            android:id="@+id/view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
        </com.google.android.youtube.player.YouTubePlayerView>

        <TextView
        </TextView>

    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/view2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="vertical">

        <com.google.android.youtube.player.YouTubePlayerView
            android:id="@+id/youtube_view_2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
        </com.google.android.youtube.player.YouTubePlayerView>

        <TextView
        </TextView>


    </RelativeLayout>
</ViewFlipper>`

0 个答案:

没有答案