是否有支持注释来表示绑定资源?
Is there a support annotation to denote binding resources?
@LayoutRes
表示布局资源(R.layout.myLayout
),@ColorRes
表示颜色资源(R.color.colorPrimary
),依此类推。是否有任何 Android 支持注释表示绑定资源 (BR.myVar
)?
数据绑定是一个比较新的特性,目前还没有针对其资源的具体注解。但是,您现在可以使用 @AnyRes
作为替代。
Use @AnyRes
to indicate that the annotated parameter can be any type of R resource.
public interface AnyRes extends annotation.Annotation
Denotes that an integer parameter, field or method return value is expected to be a resource reference of any type. If the specific type is known, use one of the more specific annotations instead, such as StringRes or DrawableRes.
@LayoutRes
表示布局资源(R.layout.myLayout
),@ColorRes
表示颜色资源(R.color.colorPrimary
),依此类推。是否有任何 Android 支持注释表示绑定资源 (BR.myVar
)?
数据绑定是一个比较新的特性,目前还没有针对其资源的具体注解。但是,您现在可以使用 @AnyRes
作为替代。
Use
@AnyRes
to indicate that the annotated parameter can be any type of R resource.
public interface AnyRes extends annotation.Annotation
Denotes that an integer parameter, field or method return value is expected to be a resource reference of any type. If the specific type is known, use one of the more specific annotations instead, such as StringRes or DrawableRes.