AndroidAnnotations——ClickEvents单击事件

ClickEvents


@Click

Since AndroidAnnotations 1.0


The  @Click annotation indicates that an activity  method must be called when the corresponding view is  clicked.
  @Click 注解表示当相对应的视图被单击时,一个activity的方法必须被调用。

The view id can be set in the annotation parameter, ie  @Click(R.id.myButton).
可以在注解参数中设置 视图id,像   @Click(R.id.myButton)

If the view id is  not set, the  name of the method will be used to guess the view id.
如果没有设置视图id,方法名将用于猜测这个视图id。

The method may have zero or one parameter, and this parameter can only be a View (the view that was clicked). The method must not be private. Two different methods cannot handle the same view.
这个方法可以无参或者有一个参数,这个参数只能是一个视图(被单击的那个)。这个方法必须不能是私有的。两个方法不能处理同一个视图。

Usage example:用例:

@Click(R.id.myButton)
void myButtonWasClicked() {
    [...]
}
@Click
void anotherButton() {
    [...]
}
@Click
void yetAnotherButton(View clickedView) {
    [...]
}

Other events 其他事件


AndroidAnnotations supports other kind of events, and it works exactly as with  @Click.
AndroidAnnotations  支持其他类型的事件,和   @Click 类似。

Currently,  AndroidAnnotations supports the following  events on views:
目前, AndroidAnnotations   支持如下这些   events   视图事件:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值