I\'m trying to set drawable resource ID to android:src of ImageView using data binding
Here is my object:
public class Recipe implem
Building upon the answer from Maher Abuthraa, this is what I ended up using in the XML:
android:src="@{context.getDrawable(recipe.imageResource)}"
The context
variable is available in binding expression without any imports. Also, no custom BindingAdapter
necessary. Only caveat: the method getDrawable
is only available since API 21.