I followed the data binding documentation for Custom Binding Adapter for image loading from official Android Developers site: http://developer.android.com/tools/data-binding/guide.html
After successfully compiling the code I get a warning which is:
Warning:Application namespace for attribute bind:imageUrl will be ignored.
My Code is as follow:
@BindingAdapter({"bind:imageUrl"})
public static void loadImage(final ImageView imageView, String url) {
imageView.setImageResource(R.drawable.ic_launcher);
AppController.getUniversalImageLoaderInstance().displayImage(url, imageView);
}
Why this warning is generated?
I believe the namespace is truly ignored in the BindingAdapter
annotation. The warning occurs if you use any namespace prefix, regardless of whether it matches the one used in your layout or not. If you omit the namespace, like so:
@BindingAdapter({"imageUrl"})
...the warning doesn't occur.
I suspect the warning exists to alert us the namespace is stripped off before the string is used as a key in the annotation's implementation. Which makes sense when you consider layouts are free to declare whatever namespaces they want, e.g. app:
or bind:
or foo:
, and the annotation needs to work across all those cases.