OneWorld
OneWorld

Reputation: 17671

Show spinner wheel instead of image while downloading the source

I am going to create a gallery view where the user shall switch between different pictures of products. On some of them is going to be a label like "sale" and a short discription. On startup I want to display a loading animation at that place until the product photo is downloaded.

  1. Use layer list or state list for one product photo?
  2. Could you please show me, how to set that up?
  3. How to make that spinner spin?
  4. How to turn it on or off (how to access the layer list through code)?

By the way, is "spinner" the best word for this? It seems to stand for several things. Feel free to edit this question, if I didn't hit the right words.

Upvotes: 1

Views: 2236

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006539

Use layer list or state list for one product photo?

Probably neither. Show your custom AnimationDrawable in the ImageView, then replace that image with the product photo when it is available. Make sure you pay attention to view recycling -- if the user scrolls while you are fetching a photo, it may be that the photo does not belong on the screen by the time the photo is fully downloaded.

How to make that spinner spin?

Use an AnimationDrawable for your progress indicator.

How to turn it on or off (how to access the layer list through code)?

Replace the image in the ImageView when you no longer wish to display the progress indicator

By the way, is "spinner" the best word for this?

No. Spinner in Android is a drop-down selection widget. I would use "progress indicator" as the term.

Upvotes: 5

Related Questions