I know this is stupid question But
I have never used android Annotation
, it just appeared with auto-complete in android studio and I thought its a good idea to use it, I'm I right?
I did my research and I learned how to use it with parameters
but I didn't find anything about how to use it with pair
and generic
here is my code
private Pair<StringRes ,DrawableRes> getRespectiveStingAndDrawableRes(String permission) {
if(permission.equals(Manifest.permission.WRITE_EXTERNAL_STORAGE))
return Pair.create(R.string.WRITE_EXTERNAL_STORAGE_permision_message,R.drawable.ic_menu_gallery);
return null;
}
and this error appeared
Error:(49, 31) error: incompatible types
required: Pair<StringRes,DrawableRes>
found: Pair<Integer,Integer>
i tried to use IntegerRes
but also not worked
note: the piar
I used is android.support.v4.util.Pair
You cannot use these annotations that way. They are mainly used to limit parameter values to a given type, e.g. @StringRes
requires that the specified int
value is a valid string resource.
For this Pair
you still have to write Integer
, since that is the actual variable type:
private Pair<Integer, Integer> getRespectiveStingAndDrawableRes(String permission) {
...
}