如何自定义JieCaoVedio的UI?
看不太懂,自己弄了下,结果起不来,求大神帮我看看。
首先是我自定义的继承JCVideoPlayer的类
public class MyVedioPlayer extends JCVideoPlayer {
public MyVedioPlayer(Context context) { super(context); }
public MyVedioPlayer(Context context, AttributeSet attrs){super(context, attrs);}
@Override
public void init(Context context) {
super.init(context);
View.inflate(context, getLayoutId(), this);
startButton = (ImageView) findViewById(R.id.start);//开始
textureViewContainer = (ViewGroup) findViewById(R.id.surface_container);//SurfaceView的容器
startButton.setOnClickListener(this);
textureViewContainer.setOnClickListener(this);
textureViewContainer.setOnTouchListener(this);
mScreenWidth = getContext().getResources().getDisplayMetrics().widthPixels;
mScreenHeight = getContext().getResources().getDisplayMetrics().heightPixels;
mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
mHandler = new Handler();
}
@Override
public int getLayoutId() {
return R.layout.jc_layout_standard;//自定义的布局文件
}
然后是我自定义的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black">
<RelativeLayout
android:id="@+id/surface_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
</RelativeLayout>
<ProgressBar
android:id="@+id/loading"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminateDrawable="@drawable/jc_loading"
android:visibility="invisible" />
<ImageView
android:id="@+id/start"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:src="@drawable/jc_click_play_selector" />
</RelativeLayout>
布局文件就是删除了我不想要的,就留了一个开始按钮和processBar
然后是RecyclerViewApapt中引用:
View view = LayoutInflater.from(context).inflate(R.layout.vedioview, viewGroup,false);//这句报错
vedioview就是引用我自定定义的MyVedioPlayer的布局文件,里面就一个MyVedioPlayer。但是就是这里报错
Binary XML file line #7: Binary XML file line #7: Error inflating class com.XXX.MyVedioPlayer