-
Notifications
You must be signed in to change notification settings - Fork 0
Resources
Since AndroidAnnotations 1.0
All @XXXRes annotations indicate that an activity field should be injected with the corresponding Android resource from your res folder. The resource id can be set in the annotation parameter, ie @StringRes(R.string.hello).
If the resource id is not set, the name of the field will be used. The field must not be private.
The @StringRes annotation can be used to retrieve string resources.
Usage example:
@EActivity
public class MyActivity extends Activity {
@StringRes(R.string.hello)
String myHelloString;
@StringRes
String hello;
}The @ColorRes annotation can be used to retrieve color resources.
Usage example:
@EActivity
public class MyActivity extends Activity {
@ColorRes(R.color.backgroundColor)
int someColor;
@ColorRes
int backgroundColor;
}@AnimationRes can be used to inject XmlResourceParser fields (not very useful) or Animation fields (much more interesting).
Usage example:
@EActivity
public class MyActivity extends Activity {
@AnimationRes(R.anim.fadein)
XmlResourceParser xmlResAnim;
@AnimationRes
Animation fadein;
}Here is the list of other supported resource annotations:
@BooleanRes@ColorStateListRes@DimensionRes@DimensionPixelOffsetRes@DimensionPixelSizeRes@DrawableRes@IntArrayRes@IntegerRes@LayoutRes@MovieRes@TextRes@TextArrayRes@StringArrayRes
AndroidAnnotations was created by Pierre-Yves Ricau and is sponsored by eBusinessInformations.
04/11/2012 The 2.7 release is out
- Get started!
- Download
- Cookbook, full of recipes
- List of all available annotations
- Release Notes
- Examples
- Read the FAQ
- Join the Mailing list
- Create an issue
- Tag on Stack Overflow