views:

52

answers:

1

I have 24 .png images and a ImageView. On user touch I change the ImageView to be one of the 24 images. I'm currently doing setImageResource(R.drawable.hour_1);, but there is a slight delay after I touch the screen and the ImageView actually changes. I figure the delay is the resource being loaded, but I can't find a better way to do this.

A: 

If it's only 24 images, you could load them all into different imageviews and then switch which one is .VISIBLE

Falmarri
I tried to load all 24 into Drawables, but I get `10-16 15:48:00.940: ERROR/dalvikvm-heap(5357): 404480-byte external allocation too large for this process.` when I try to run it. But if I comment out a single one, any one, it runs fine. All the .png's added together is only like 150kb, I thought I had plenty of memory to work with.
Tom
Are the images ordered? You could load the next one before the user touches the current one
Falmarri
@Tom: I don't exactly know the specifics in Android, but I would assume that images would have to be uncompressed when loaded into memory for displaying. 24 images is small number though, so it should fit into memory unless you have a decomprssion bomb.
Lie Ryan
The images are not ordered. Each image is only 4kb so I'm not sure why I can't have 24 Drawable instances. Maybe the way I instantiate them is bad? What would be the proper way to do Drawable one = ***** to set 'one' to a res/drawable?
Tom