我在片段内部包含JWPlayerView的简单布局:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray"
android:orientation="vertical"
tools:context=".MainActivity">
<com.longtailvideo.jwplayer.JWPlayerView
android:id="@+id/jwplayer"
android:layout_width="match_parent"
android:layout_height="0dp" />
</FrameLayout>
但Android Studio 2.0无法在其预览视图中呈现它。 而是显示此错误:
java.lang.NullPointerException
at com.longtailvideo.jwplayer.JWPlayerView.setLayoutParams(SourceFile:528)
at android.view.ViewGroup.addViewInner(ViewGroup.java:3524)
at android.view.ViewGroup.addView(ViewGroup.java:3380)
at android.view.ViewGroup.addView(ViewGroup.java:3356)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:759)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
有人知道如何解决它吗?