Android 失业或不工作

Android 失业或不工作,android,Android,当我试图膨胀布局时,我遇到了一个例外。据我所知,所有必要的方法都是公开的。为什么会出现这种故障?我如何修复它 AllMediaView类的构造函数: public AllMediaView(Context context) { super(context); LayoutInflater layoutInflater = LayoutInflater.from(context); View view = layoutInflater.inflate(R.layout.vi

当我试图膨胀布局时,我遇到了一个例外。据我所知,所有必要的方法都是公开的。为什么会出现这种故障?我如何修复它

AllMediaView类的构造函数:

public AllMediaView(Context context) {
    super(context);
    LayoutInflater layoutInflater = LayoutInflater.from(context);
    View view = layoutInflater.inflate(R.layout.view_all_media, this);
    initViews(context, view);
}

public AllMediaView(Context context, AttributeSet attrs) {
    super(context, attrs);
    LayoutInflater layoutInflater = LayoutInflater.from(context);
    View view = layoutInflater.inflate(R.layout.view_all_media, this);
    initViews(context, view);
}

public AllMediaView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    LayoutInflater layoutInflater = LayoutInflater.from(context);
    View view = layoutInflater.inflate(R.layout.view_all_media, this);
    initViews(context, view);
}

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public AllMediaView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    LayoutInflater layoutInflater = LayoutInflater.from(context);
    View view = layoutInflater.inflate(R.layout.view_all_media, this);
    initViews(context, view);
}
SocialMediaView类的构造函数:扩展AllMediaView

public SocialMediaView(Context context) {
    super(context);
    initView(context);
}

public SocialMediaView(Context context, AttributeSet attrs) {
    super(context, attrs);
    initView(context);
}

public SocialMediaView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    initView(context);
}
查看\u all\u media.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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/all_media_view_iv_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.michaelgarnerdev.allmediaview.AllMediaImageView
            android:id="@+id/all_media_view_iv_photo"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:contentDescription="@string/cd_all_media_view_image"/>
    </RelativeLayout>

    <FrameLayout
        android:id="@+id/all_media_view_rl_video_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/black">

        <com.michaelgarnerdev.allmediaview.AllMediaVideoView
            android:id="@+id/all_media_view_cvv_video"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"/>

        <com.michaelgarnerdev.allmediaview.AllMediaMediaController
            android:id="@+id/all_media_view_cmc_controls"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center_horizontal"
            android:elevation="4dp"/>

        <ProgressBar
            android:id="@+id/all_media_view_video_loading_progress"
            android:layout_width="50dip"
            android:layout_height="50dip"
            android:layout_gravity="center"
            android:visibility="gone"/>
    </FrameLayout>
</FrameLayout>

您是否可以共享正在膨胀的布局的XML文件? 有一次,当我在布局中使用“视图”而不是“视图”时,我遇到了同样的无法解释的错误。

找到了它

<com.someDomain.allmediaview.AllMediaVideoView

什么扩展AllMediaView类?@IgorB SocialMediaView扩展AllMediaView谢谢,这确实有帮助。
<com.someDomain.allmediaview.AllMediaVideoView