Search code examples
androidandroid-annotations

Annotations documentation


I would like to know what happens really happens if my XML file does not contain certain view and I use @ViewById annotation to inject that non existing view into an attribute. Here is the documentation for this annotation but this case is not considered there. Do you know about any other official documentation describing this?


Solution

  • The injected field simply will be null. The @ViewById annotation calls findViewById() under the hood, which returns null if the view with the given ID is not present.