看不太懂,自己弄了下,结果起不来,求大神帮我看看。
首先是我自定义的继承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
首先是我自定义的继承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
public static void hideSupportActionBar(Context context) {
if (ACTION_BAR_EXIST) {
ActionBar ab = JCUtils.getAppCompActivity(context).getSupportActionBar();
if (ab != null) {
ab.setShowHideAnimationEnabled(false); //报错ActionBar.setShowHideAnimationEnabled can only be called from
// within the same library group (groupId=com.android.support)
ab.hide();
}
}
if (TOOL_BAR_EXIST) {
JCUtils.getAppCompActivity(context).getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
} public static void showSupportActionBar(Context context) {
if (ACTION_BAR_EXIST) {
ActionBar ab = JCUtils.getAppCompActivity(context).getSupportActionBar();
if (ab != null) {
ab.setShowHideAnimationEnabled(false);//这里报错和上面一样
ab.show();
}
}
if (TOOL_BAR_EXIST) {
JCUtils.getAppCompActivity(context).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}但是这是人家写好的,我就是把jcvideoplayer-lib当作libiary引到了我的工程,并且把build.gradle改成和我一样的版本号