InferringIDFromMethodName - shiraji/androidannotations GitHub Wiki
With event binding annotations, like @Click
or @ItemClick
it is not necessary to pass the resource ID as an annotation parameter. In that case, AndroidAnnotations can infer the resource ID from the method name.
For example the method:
@Click
void loginButtonClicked() {
}
will generate a listener which will be set up on the View
with ID R.id.loginButton
.
You can use use two types of notations for method names:
<resourceID>()
<resourceId><actionName>()
The actionName
is derived from the annotation name, for example it is Clicked for @Click
or Touched for @Touch
.
If you prefer to use snake_case for your resource names, but still you want to use the standard Java camelCase for method names, that is no problem: AndroidAnnotations can convert camel case method names to snake case resource IDs. For example:
@Click
void loginButtonClicked() {
}
will work if the ID name is R.id.login_button
.