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

657 Views Asked by At

I try to create Epoxy ModelView according to their Wiki documentation. I am getting this error: "Epoxy Processor Exception: Unable to get layout resource for view TitleModel"

This is my Java code:

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);
    }
}
2

There are 2 best solutions below

0
On

You have to put a PackageConfig interface in your Model class package:

package com.example;

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

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

You have to define an autoLayout or defaultLayout.

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

Source