views:

49

answers:

1

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.

+2  A: 

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.

CommonsWare
@OneWorld: Doubtful. Use a RelativeLayout, or perhaps a LinearLayout.
CommonsWare
But for the "sales" and description label on top of the photo I need layer list. Do I?
OneWorld
And then I can use this RelativeLayout as item in the gallery, right?
OneWorld
@OneWorld: Yes. Have your `Adapter` used for your `Gallery` inflate a layout using a `RelativeLayout` containing your label(s) and `ImageView`.
CommonsWare