flo flo - 1 year ago 133
Android Question

How to display a loading screen while fetching data with Volley in Android?

I want to load userdata e.g. Username and Email from my database into some Text Views. When the activity opens there is always a delay. I'm fetching the data in the onCreate method.
How do I display a loading icon, or can I prevent this delay?

Answer Source

You can either use the Android ProgressBar widget; doc here. Or show some splash screen, which can either be an ImageView or even it's own layout. The key is to show the ProgressBar/splash screen before initiating the Volley request. Then in the Volley request's onResponse() or onResponseError(), show the resulting data or an error message respectively, and of course hide the ProgressBar or splash screen.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download