【问题标题】:Overlay YouTubePlayerFragment on List view在列表视图上覆盖 YouTubePlayerFragment
【发布时间】:2014-04-19 23:40:21
【问题描述】:

我希望将 YouTubePlayerFragment 覆盖在我的自定义视频列表视图上,但我收到错误 [应用不幸停止].. 这是我的布局文件:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout   xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="20dip">

<EditText
    android:id="@+id/userId"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:imeOptions="actionGo"
    android:inputType="text" />

<Button
    android:id="@+id/searchButton"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:onClick="getUserYouTubeFeed"
    android:text="Click to Search" />

<com.gagan.ui.widget.VideosListView
    android:id="@+id/videosListView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />


 <com.gagan.ui.widget.VideosListView
 android:id="@+id/videosListViewHistory"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent" />


 <com.gagan.ui.widget.VideosListView
 android:id="@+id/videosListViewFavourite"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent" />


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

    </FrameLayout  >

活动代码:

 youTubePlayerFragment.getView().setVisibility(View.VISIBLE);
 fm.beginTransaction().setCustomAnimations(R.anim.fade_in,R.anim.fade_out);
 fm.beginTransaction().add(R.id.videosListView,youTubePlayerFragment,"yt_id1");     
        fm.beginTransaction().addToBackStack(null);
        fm.beginTransaction().commit();
        player.setPlayerStateChangeListener(playerStateChangeListener);
        this.playerInstance = player;
        //player.cueVideo(videoID);
        player.loadVideo(videoID);

我有兴趣:

1) 有任何更正吗? 1)我错过了什么吗? 2) 有更好的设计或替代方案吗?

感谢和问候!

【问题讨论】:

    标签: java android youtube-api


    【解决方案1】:

    得到解决方案...将布局更改为 RelativeLayout 和 onCreate 方法隐藏片段:

    youTubePlayerFragment.getView().setVisibility(View.GONE);
    

    & on OnItemClickListener 只是用参数实例化播放器并显示 youtubefragment:

    youTubePlayerFragment.getView().setVisibility(View.VISIBLE);
    

    RelativeLayout 会在 listView 上堆叠[overlay]..

    谢谢!

    【讨论】:

      猜你喜欢
      • 2014-04-02
      • 1970-01-01
      • 1970-01-01
      • 2019-09-03
      • 1970-01-01
      • 2013-06-25
      • 1970-01-01
      • 1970-01-01
      • 2012-12-10
      相关资源
      最近更新 更多