ImageView setImageResource problem

All your problems with Audio, Video and Images.

ImageView setImageResource problem

Postby guinnessSquirrel » Fri Aug 07, 2009 9:08 pm

Hi, all.

Just joined this forum - seems like there's a lot of good stuff on here, so fingers crossed someone can help with this little problem! ;)

I'm putting together a simple card game, so I need to turn over a card on click, do some logic, then sometimes turn it back over, sometimes leave it face down. The logic is fine, but when I was handling all the logic in the onClick, it was never showing the card face. I saw on Google groups that it doesn't update the ImageView until you end function and hand control back to Android, so I broke all my logic into a separate function.

My new function works fine if you call it direct (except that then the card face still doesn't show), but when I put it into a new thread (at which point the card does show), it crashes when I try to flip it back to the back of the card.

The line which is crashing is

((ImageView) gridview.getChildAt(mIntFirstCardID)).setImageResource(R.drawable.cardback1);

I've done some debug calls and successfully called properties of GridView, ImageView and cardback1, so I think it must be a problem with setImageResource itself. Has anyone else had problems calling this away from the main thread?

Once Poster
Once Poster
Posts: 1
Joined: Fri Aug 07, 2009 9:01 pm


Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 4 guests