How bind an image to ImageView?


#1

I use ImageViews instead of Buttons and want binding some images to them.

public String getBackground(){
return mPicture.getName();
}

ImageButton
tools:text="Item name"
android:layout_width=“match_parent"
android:layout_height=“200dp"
android:background=”@{viewModel.background}“
android:contentDescription=”@string/letter”>
ImageButton>

Could you help?


#2

A lot of missing details in your question, like whether your image object is a drawable res or a Bitmap, your complete layout file, etc…,. However, take a look at this post from SO, it may help you: