AndroidAnnotations——TextChangeEvents文本改变事件

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
 }
 
 @TextChange
 void 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
 }
 
 @BeforeTextChange
 void 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
 }
 
 @AfterTextChange
 void 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
 }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值