java.lang.IllegalStateException:未连接.致电connect() – YouTube API
作者:互联网
我试图让ThumbnailView在我的ArrayAdapter上运行,但是我收到以下错误:
java.lang.IllegalStateException: Not connected. Call connect() and wait for onConnected() to be called.
at com.google.android.youtube.player.internal.r.i(Unknown Source)
at com.google.android.youtube.player.internal.o.k(Unknown Source)
at com.google.android.youtube.player.internal.o.a(Unknown Source)
at com.google.android.youtube.player.internal.p.<init>(Unknown Source)
at com.google.android.youtube.player.internal.ac.a(Unknown Source)
at com.google.android.youtube.player.YouTubeThumbnailView$a.a(Unknown Source)
我的ArrayAdapter看起来像这样:
我的xml video_items.xml看起来像这样:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@drawable/listviewbox"
android:padding="10dp"
android:layout_height="match_parent">
<!-- Video Thumbnail -->
<com.google.android.youtube.player.YouTubeThumbnailView
android:id="@+id/imageView_thumbnail"
android:layout_width="85dp"
android:layout_height="85dp"
android:layout_alignParentLeft="true"
android:layout_margin="5dp"
android:background="@color/panelcolor"
android:scaleType="centerCrop" />
<!-- Video Title -->
<TextView
android:id="@+id/video_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imageView_thumbnail"
android:layout_toRightOf="@+id/imageView_thumbnail"
android:paddingBottom="5dp"
android:paddingRight="5dp"
android:text="@string/videotext"
android:textColor="@android:color/black"
android:textSize="16sp" />
</RelativeLayout>
这可能有什么问题?
解决方法:
在长ListView中显示YoutubeThumbnailView时,同样的事情发生在我身上.我找到了提到的解决方案f.e.这里:
https://github.com/youtube/yt-android-player/issues/2#issuecomment-58913900
或者在这里:
https://code.google.com/p/gdata-issues/issues/detail?id=7533#c6
解决方案是将YoutubeThumbnailView包装在ViewHolder对象中,跟踪其初始化状态.初始化(..)方法可能不会被多次调用.
不幸的是,例外不会很快导致.
标签:java,android,android-youtube-api 来源: https://codeday.me/bug/20190623/1270106.html