Inspectopedia Help

Add Explicit Cast

Add Explicit Cast

In Android O, the findViewById signature switched to using generics, which means that most of the time you can leave out explicit casts and just assign the result of the findViewById call to variables of specific view classes.

However, due to language changes between Java 7 and 8, this change may cause code to not compile without explicit casts. This lint check looks for these scenarios and suggests casts to be added now such that the code will continue to compile if the language level is updated to 1.8.

Issue id: FindViewByIdCast

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