当前位置: 代码迷 >> 综合 >> AndroidAnnotations——SeekBarEventsSeekBar事件
  详细解决方案

AndroidAnnotations——SeekBarEventsSeekBar事件

热度:52   发布时间:2023-12-11 23:59:20.0
AndroidAnnotation seekbar

目录(?)[+]

SeekBarEvents

Since AndroidAnnotations 2.7


You can bind methods to handle specific events from  SeekBar view.
你可以绑定方法去处理来自   SeekBar 视图的指定的事件。

@SeekBarProgressChange


This annotation is intended to be used on methods to receive events defined by SeekBar.OnSeekBarChangeListener.onProgressChanged(SeekBar, int, boolean) when the progress level of a  SeekBar view has changed.
这个注释表明,当   SeekBar  视图 的值改变时,加了注解的方法就可以接收由 SeekBar.OnSeekBarChangeListener.onProgressChanged(SeekBar, int, boolean)   定义的改变事件。

The annotation value should be one or several R.id.* fields that refers to anandroid.widget.SeekBar. If not set, the method name will be used as the R.id.* field name.注解值应该是一个或多个引用了android.widget.SeekBar R.id.*字段。如果没有设置,那么会用方法名作为 R.id.*

The method may have multiple parameter :方法可以有多个参数:

  • android.widget.SeekBar parameter to determine which view has targeted this event
  • 一个 android.widget.SeekBar参数来决定哪个视图被绑定到这个事件上
  • An int parameter named progress to get the progress level of the SeekBar
  • 一个命名为progress的 int 值参数来获取SeekBar的值
  • boolean parameter named fromUser to determine if this event is triggered by the user
  • 一个命名为FromUser的 boolean 值参数来决定这个事件是否由用户触发。

All of those parameters are parameter are optional.所有的参数都是可选的。

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

 @SeekBarProgressChange(R.id.seekBar)void onProgressChangeOnSeekBar(SeekBar seekBar, int progress, boolean fromUser) {
        // Something Here}@SeekBarProgressChange(R.id.seekBar)void onProgressChangeOnSeekBar(SeekBar seekBar, int progress) {
        // Something Here}@SeekBarProgressChange({
        R.id.seekBar1, R.id.seekBar2})void onProgressChangeOnSeekBar(SeekBar seekBar) {
        // Something Here}@SeekBarProgressChange({
        R.id.seekBar1, R.id.seekBar2})void onProgressChangeOnSeekBar() {
        // Something Here}

@SeekBarTouchStart and @SeekBarTouchStop

Those annotations are intended to be used on methods to receive events defined bySeekBar.OnSeekBarChangeListener.onStartTrackingTouch(SeekBar seekBar) andSeekBar.OnSeekBarChangeListener.onStopTrackingTouch(SeekBar seekBar) when the user has started or finished to move the cursor of the targeted SeekBar.这些注解表示,当用户开始或者结束移动 SeekBar 视图的光标时,加了注解的方法就可以接收由SeekBar.OnSeekBarChangeListener.onStartTrackingTouch(SeekBar seekBar) 和SeekBar.OnSeekBarChangeListener.onStopTrackingTouch(SeekBar seekBar) 定义的事件

The annotation value should be one or several R.id.* fields that refers to an android.widget.SeekBar. If not set, the method name will be used as the R.id.* field name.注解值应该是一个或多个引用了android.widget.SeekBarR.id.*字段。如果没有设置,那么会用方法名作为 R.id.*

The method can have zero or one parameter of type SeekBar.方法中可以无参或者有一个SeekBar类型的参数。

  相关解决方案