Image Loading With DataBinding in Android

Image Loading With DataBinding

We have already seen DataBinding Basics and setting fonts through DataBinding in previous tutorials. Today we will take a look at Image loading with databinding .

Step 1 : Define POJO/Model class

Step 2 : Define custom binding class.

Here i have used Picasso for image loading, you can replace this code with your own image loader like Glide, UniversaImageLoader etc.

Step 3 : Create layout file and add the new image_url attribute to your ImageView.Custom attributes need to use the app namespace instead of android.

Step 4 : Finally in your activity class set view with DataBindingUtils.

Here it is, you are done with image loading from url.

Image loading with databinding

Setting custom font through XML with DataBinding
Two-way DataBinding in Android

  • Simply Awesome and Useful Tutorials on Data Binding 🙂 Keep Writing 🙂