Missing View constructors for XML inflation
Missing View constructors for XML inflation
Some layout tools (such as the Android layout editor) need to find a constructor with one of the following signatures:
* View(Context context)
* View(Context context, AttributeSet attrs)
* View(Context context, AttributeSet attrs, int defStyle)
If your custom view needs to perform initialization which does not apply when used in a layout editor, you can surround the given code with a check to see if View#isInEditMode()
is false, since that method will return false
at runtime but true within a user interface editor.
Issue id: ViewConstructor
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for Android 2023.3, Qodana for JVM 2023.3 |
Plugin: | Android, 2022.3.1 Beta 2 |
Last modified: 13 July 2023