-
Notifications
You must be signed in to change notification settings - Fork 0
Library projects
The id fields of the R inner classes of an Android project, such as R.id.someId, are static final constants. This allows us to use them in annotations parameter, which only accept compile time constant values.
To solve problems related to library projects, the Android team decided that the R inner classes fields of a library project would not be static final anymore. Which means we can't use them in annotations in library projects any more.
Prior to AndroidAnnotations 2.7, you can still use it in a library project but with a few limitations :
-
View injection and event binding can be done through "convention naming" instead of specifying the R id in the annotation (eg, if you have a
R.id.my_viewid, name your@ViewByIdannotated fieldmyViewor your@Clickannotated method "myViewClicked"). -
Specifying the layout will have to be done using setContentView in onCreate. View binding & injection still work even if you inject the layout manually.
See this thread, this ACRA issue and this AA issue for more information.
Since AndroidAnnotations 2.7
To enable full AndroidAnnotations support in library projects, we added a new resName attribute on all annotations that accept an Android resource id.
This enables you to specify the resource id name as a String. Please note that AndroidAnnotations checks that the name exists at compile time.
A simple example:
@EActivity(resName="myLayout")
public class MyActivity extends Activity {
@Click(resName={"myButton1", "myButton2"})
public void someButtonClicked() {
}
}AndroidAnnotations was created by Pierre-Yves Ricau and is sponsored by eBusinessInformations.
27/12/2013 The 3.0 release is out !
- Get started!
- Download
- Cookbook, full of recipes
- Customize annotation processing
- List of all available annotations
- Release Notes
- Examples
- Read the FAQ
- Join the Mailing list
- Create an issue
- Tag on Stack Overflow