幻灯片标题解析设置程序我阅读了这张幻灯片,但是我不理解BindingMethod,我们必须在任何地方编写此方法吗?或只是说明东西是如何工作的。
I know for exemple we must write write BindingAdapter for some attribue like bellow
<TextView android : text = "@{myVariable}"/>
textView.setText(myVariable);
<ImageView android:src="@{user.image}"/>
imageView.setImageDrawable(user.image);
@BindingMethod(
type = android.widget.ImageView.class,
attribute = "android:src",
method = "setImageDrawable")
答案 0 :(得分:0)
I think method 1 is equivalente method 2, so we have choise to write in our java method 1 or method2 <ImageView android:src="@{user.image}"/> // method 1 imageView.setImageDrawable(user.image); // method 2 @BindingMethod( type = android.widget.ImageView.class, attribute = "android:src", method = "setImageDrawable")
但是现在我想知道何时使用@BindingMethod和何时使用@BindingAdapter。