当前位置: 代码迷 >> 综合 >> AndroidAnnotations——TextChangeEvents文本改变事件
  详细解决方案

AndroidAnnotations——TextChangeEvents文本改变事件

热度:68   发布时间:2023-12-11 23:59:09.0
AndroidAnnotation

目录(?)[+]

TextChangeEvents

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:
这个注释表明,当TextView或者其子类的文本值 改变时,加了注解的方法就可以接收由 android.text.TextWatcher.onTextChanged(CharSequence s, int start, int before, int count) 定义的改变事件。注解值应该是一个或多个引用了TextView或者其子类   R.id.* 字段。如果没有设置,那么会用方法名作为   R.id.* 。该方法可以有多个参数:
  • android.widget.TextView parameter to know which view has received this event
  • 一个 android.widget.TextView参数,表示接收到事件的视图
  • java.lang.CharSequence parameter to get the modified text.
  • 一个 java.lang.CharSequence参数,获取修改后的文本
  • An int parameter named start to get the start position of the modified text.
  • 一个名为start的int类型参数,获取修改后文本的起始位置
  • An int parameter named before to know the text length before modification.
  • 一个名为before的int类型参数,表示修改前的文本长度
  • An int parameter named count to know the number of modified characters.
  • 一个名为count的int类型参数,表示被修改字符的数量

Some usage examples of @TextChange annotation:@TextChange 注解的一些用例:

 @TextChange(R.id.helloTextView)void onTextChangesOnHelloTextView(CharSequence text, TextView hello, int before, int start, int count) {
        // Something Here}@TextChangevoid helloTextViewTextChanged(TextView hello) {
        // Something Here}@TextChange({
        R.id.editText, R.id.helloTextView})void onTextChangesOnSomeTextViews(TextView tv, CharSequence text) {
        // Something Here}@TextChange(R.id.helloTextView)void onTextChangesOnHelloTextView() {
        // Something Here}

@BeforeTextChange

This annotation is intended to be used on methods to receive events defined byandroid.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:这个注释表明,当TextView或者其子类的文本值改变之前,加了注解的方法就可以接收由android.text.TextWatcher.beforeTextChanged(CharSequence s, int start, int count, int after)定义的改变事件。注解值应该是一个或多个引用了TextView或者其子类 R.id.*字段。如果没有设置,那么会用方法名作为 R.id.*。该方法可以有多个参数:

  • android.widget.TextView parameter to know which view has targeted this event
  • 一个 android.widget.TextView参数,表示接收到事件的视图
  • An java.lang.CharSequence parameter to get the text before modification.
  • 一个 java.lang.CharSequence参数,获取修改前的文本
  • An int parameter named start to get the start position of the modified text.
  • 一个名为start的int类型参数,获取修改后文本的起始位置
  • An int parameter named count to know the number of modified characters.
  • 一个名为count的int类型参数,表示被修改字符的数量
  • An int parameter named after to know the text length after the text modification.
  • 一个名为before的int类型参数,表示修改后的文本长度

Some usage examples of @BeforeTextChange annotation:@BeforeTextChange 注解的一些用例:

 @BeforeTextChange(R.id.helloTextView)void beforeTextChangedOnHelloTextView(TextView hello, CharSequence text, int start, int count, int after) {
        // Something Here}@BeforeTextChangevoid helloTextViewBeforeTextChanged(TextView hello) {
        // Something Here}@BeforeTextChange({
        R.id.editText, R.id.helloTextView})void beforeTextChangedOnSomeTextViews(TextView tv, CharSequence text) {
        // Something Here}@BeforeTextChange(R.id.helloTextView)void beforeTextChangedOnHelloTextView() {
        // Something Here}

@AfterTextChange

This annotation is intended to be used on methods to receive events defined byandroid.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 severalR.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:


这个注释表明,当TextView或者其子类的文本值 改变后,加了注解的方法就可以接收由 android.text.TextWatcher.afterTextChanged(Editable s)   定义的改变事件。 注解值应该是一个或多个引用了TextView或者其子类   R.id.* 字段。如果没有设置,那么会用方法名作为   R.id.* 。该方法可以有多个参数:
  • android.widget.TextView parameter to know which view has targeted this event
  • 一个 android.widget.TextView参数,表示接收到事件的视图
  • An android.text.Editable to make changes on modified text.
  • 一个android.text.Editable 参数,表示对已经修改的文本进行确认

Some usage examples of @AfterTextChange annotation :

 @AfterTextChange(R.id.helloTextView)void afterTextChangedOnHelloTextView(Editable text, TextView hello) {
        // Something Here}@AfterTextChangevoid helloTextViewAfterTextChanged(TextView hello) {
        // Something Here}@AfterTextChange({
        R.id.editText, R.id.helloTextView})void afterTextChangedOnSomeTextViews(TextView tv, Editable text) {
        // Something Here}@AfterTextChange(R.id.helloTextView)void afterTextChangedOnHelloTextView() {
        // Something Here}
  相关解决方案