简体   繁体   English

环氧树脂处理器异常:无法获取视图模型视图的布局资源

[英]Epoxy Processor Exception: Unable to get layout resource for view ModelView

I try to create Epoxy ModelView according to their Wiki documentation.我尝试根据他们的Wiki文档创建 Epoxy ModelView。 I am getting this error: "Epoxy Processor Exception: Unable to get layout resource for view TitleModel"我收到此错误:“环氧树脂处理器异常:无法获取视图 TitleModel 的布局资源”

This is my Java code:这是我的 Java 代码:

import ...
@ModelView
public class ModelViewA extends LinearLayout{
    private TextView titleTextView;
    @TextProp String title;
    @CallbackProp @Nullable View.OnClickListener clickListener;

    public ModelViewA(Context context) {
        super(context);
        inflate(getContext(), R.layout.title, this);
        titleTextView = findViewById(R.id.title_text_view);
    }

    @AfterPropsSet
    void postBindSetup() {
        titleTextView.setText(title);
        titleTextView.setOnClickListener(clickListener);
    }
}

You have to put a PackageConfig interface in your Model class package:您必须在 Model class package 中放置一个 PackageConfig 接口:

package com.example;

import com.airbnb.epoxy.PackageModelViewConfig;
import com.example.R;

@PackageModelViewConfig(rClass = R.class)
public interface PackageConfig {}

You have to define an autoLayout or defaultLayout .您必须定义一个autoLayoutdefaultLayout

@ModelView(autoLayout = Size.MATCH_WIDTH_WRAP_HEIGHT)
public class MyView extends FrameLayout {
   ...
}

Source 资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法为线性布局设置背景资源 - Unable to Set Background Resource for Linear Layout Android以编程方式添加布局资源以进行查看 - Android programatically add layout resource to view Android:找不到资源ID异常 - Android: Unable to find resource ID Exception 无法从Jedis获取资源 - Unable to get resource from jedis 不寻常的致命异常:无法在以下行上启动活动ComponentInfo:actionBar.setCustomView(R.layout.actionbar_custom_view_home); - Unusual FATAL EXCEPTION: Unable to start activity ComponentInfo on the line: actionBar.setCustomView(R.layout.actionbar_custom_view_home); 当单击回收站视图上的项目视图而不是数据和活动 lauch 时,如何摆脱资源未找到异常,它会使应用程序崩溃 - How to get rid of the resource not found exception when clicked on item view on recycler view and instead of data and activity lauch, it crashes app 布局xml中具有自定义视图的空指针异常 - Null pointer exception with custom view in layout xml Recycler View 无法加载布局中的数据 - Recycler View Unable to load data in the layout 获取自定义视图的ViewGroup(布局) - Get ViewGroup(Layout) of custom view 无法将视图添加到布局中的现有视图 - Unable to add views to an existing view in the layout
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM