You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Csaba Kozák edited this page Mar 16, 2016
·
11 revisions
Since AndroidAnnotations 2.6
@TextChange
This annotation is intended to be used on methods to receive events defined by android.text.TextWatcher.onTextChanged(CharSequence s, int start, int before, int count) when the text is changed on the targeted TextView or subclass of TextView. The annotation value should be one or several R.id.* fields that refers to TextView or subclasses of TextView. If not set, the method name will be used as the R.id.* field name. The method may have multiple parameter:
A android.widget.TextView parameter to know which view has received this event
A java.lang.CharSequence parameter to get the modified text.
An int parameter named start to get the start position of the modified text.
An int parameter named before to know the text length before modification.
An int parameter named count to know the number of modified characters.
Some usage examples of @BeforeTextChange annotation:
@TextChange(R.id.helloTextView)
voidonTextChangesOnHelloTextView(CharSequencetext, TextViewhello, intbefore, intstart, intcount) {
// Something Here
}
@TextChangevoidhelloTextViewTextChanged(TextViewhello) {
// Something Here
}
@TextChange({R.id.editText, R.id.helloTextView})
voidonTextChangesOnSomeTextViews(TextViewtv, CharSequencetext) {
// Something Here
}
@TextChange(R.id.helloTextView)
voidonTextChangesOnHelloTextView() {
// Something Here
}
@BeforeTextChange
This annotation is intended to be used on methods to receive events defined by android.text.TextWatcher.beforeTextChanged(CharSequence s, int start, int count, int after) before the text is changed on the targeted TextView or subclass of TextView. The annotation value should be one or several R.id.* fields that refers to TextView or subclasses of TextView. If not set, the method name will be used as the R.id.* field name. The method may have multiple parameters:
A android.widget.TextView parameter to know which view has targeted this event
An java.lang.CharSequence parameter to get the text before modification.
An int parameter named start to get the start position of the modified text.
An int parameter named count to know the number of modified characters.
An int parameter named after to know the text length after the text modification.
Some usage examples of @BeforeTextChange annotation:
@BeforeTextChange(R.id.helloTextView)
voidbeforeTextChangedOnHelloTextView(TextViewhello, CharSequencetext, intstart, intcount, intafter) {
// Something Here
}
@BeforeTextChangevoidhelloTextViewBeforeTextChanged(TextViewhello) {
// Something Here
}
@BeforeTextChange({R.id.editText, R.id.helloTextView})
voidbeforeTextChangedOnSomeTextViews(TextViewtv, CharSequencetext) {
// Something Here
}
@BeforeTextChange(R.id.helloTextView)
voidbeforeTextChangedOnHelloTextView() {
// Something Here
}
@AfterTextChange
This annotation is intended to be used on methods to receive events defined by android.text.TextWatcher.afterTextChanged(Editable s) after the text is changed on the targeted TextView or subclass of TextView. The annotation value should be one or several R.id.* fields that refers to TextView or subclasses of TextView. If not set, the method name will be used as the R.id.* field name. The method may have multiple parameter:
A android.widget.TextView parameter to know which view has targeted this event
An android.text.Editable to make changes on modified text.
Some usage examples of @BeforeTextChange annotation :
@AfterTextChange(R.id.helloTextView)
voidafterTextChangedOnHelloTextView(Editabletext, TextViewhello) {
// Something Here
}
@AfterTextChangevoidhelloTextViewAfterTextChanged(TextViewhello) {
// Something Here
}
@AfterTextChange({R.id.editText, R.id.helloTextView})
voidafterTextChangedOnSomeTextViews(TextViewtv, Editabletext) {
// Something Here
}
@AfterTextChange(R.id.helloTextView)
voidafterTextChangedOnHelloTextView() {
// Something Here
}
Since AndroidAnnotations 3.1
@EditorAction
This annotation is intended to be used on methods to receive events defined by android.widget.TextView.OnEditorActionListener#onEditorAction(android.widget.TextView, int, android.view.KeyEvent) when an action is performed on the editor.
The annotation value should be one or several R.id.* fields that refers to TextView or subclasses of TextView. If not set, the method name will be used as the R.id.* field name.
The method may have multiple parameters:
A android.widget.TextView parameter to know which view has targeted this event.
An int parameter to get the actionId.
A android.view.KeyEvent parameter.
The return type of the method can be either void or boolean. In case of boolean, the value returned from the annotated method will be returned in the generated listener method (indicating event consumption). If the annotated method is void, always true will be returned in the listener method (so the event is consumed).
Some usage examples of @EditorAction annotation:
@EditorAction(R.id.helloTextView)
voidonEditorActionsOnHelloTextView(TextViewhello, intactionId, KeyEventkeyEvent) {
// Something Here
}
@EditorActionvoidhelloTextViewEditorAction(TextViewhello) {
// Something Here
}
@EditorAction({R.id.editText, R.id.helloTextView})
voidonEditorActionsOnSomeTextViews(TextViewtv, intactionId) {
// Something Here
}
@EditorAction(R.id.helloTextView)
voidonEditorActionsOnHelloTextView() {
// Something Here
}
@EditorAction(R.id.helloTextView)
booleanonEditorActionsOnHelloTextView() {
// Something Herereturnfalse;
}
Since AndroidAnnotations 4.0.0
As of AndroidAnnotations 4.0.0 any subclass of TextView can be passed to the methods (eg. EditText).