In AndroidStudio, we could just use @IntegerRes
to denote an Int
parameter must be a resource.
If we use an Int
instead of Resource
value, it will complaint dynamically (while we're coding, before we compile)
Expected resource of type integer less... (⌘F1)
Ensures that resource id's passed to APIs are of the right type; for example, calling Resources.getColor(R.string.name) is wrong.
Click into @IntegerRes
would see the below code.
/**
* Denotes that an integer parameter, field or method return value is expected
* to be an integer resource reference (e.g. {@code android.R.integer.config_shortAnimTime}).
*/
@Documented
@Retention(CLASS)
@Target({METHOD, PARAMETER, FIELD, LOCAL_VARIABLE})
public @interface IntegerRes {
}
I want to look into how this annotation is processed dynamically, so I could make my annotation. Where could I find the source of this code? (I thought all Android code are open source)