InflateException with custom View class

后端 未结 1 866
遇见更好的自我
遇见更好的自我 2020-12-04 04:18

I want to simply draw a rectangle over an ImageView. Here is the ImageViewHighlight class:

public class ImageViewHighlight extends          


        
相关标签:
1条回答
  • 2020-12-04 04:57

    InflateException: Binary XML file line #6: Error inflating class com.example.highlight.ImageViewHighlight indicates the error is in ImageViewHighlight.

    NoSuchMethodException indicates a method is missing.

    <init> [class android.content.Context, interface android.util.AttributeSet] indicates the method missing is a constructor that takes a Context and an AttributeSet as parameters.

    => You need to implement this method by calling the super() with the same arguments.

    public ImageViewHighlight(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    
    0 讨论(0)
提交回复
热议问题