-->

How to make a Glide Placeholder- Show loading spinner before content appears

In this tutorial, we are going to learn how to show a loading placeholder before the final content appears.

What you need:

1. progress_animation.xml

2.progress_image.png

After downloading, extract the zip file to any folder (remember the folder).

Now let's open our project.  Go to menu and select resources.



Then select drawable folder.


Click on the add file icon on the top right. Then select the two files you extracted earlier.


The files should look like this after you have picked them.
Now go back to your logic editor. 

"For this tutorial, we will show loader when waiting for images to load in custom list view (Same logic can be applied anywhere)."


Open your onBindCustomView. Create a string "link" or any name you wish.

Then get the link of image at position to string 'link". After that add an ASD block and paste this code in it ;

Glide 

.with(ProjectsActivity.this) 

//Change ProjectsActivity to your activity name

.load(link)

//Link is the string your made, change name if you used other name

.placeholder(R.drawable.progress_animation) 

//Progress_animation is the name of xml file you added in resources

.into(imageview1);

//Imageview1 is name of your imageview, change accordingly if it does not apply to you



You are done, now run your project and enjoy.

See Also :