Hi. I've been having the same problem - working on a card game, and I need to do some actions when the player picks a card. The card may be left face up, or may be turned back over. The problem I was having, as above, was that if I handled all the logic in the onClick(), it didn't display the face of the card, as I'd already flipped it back over before the onClick function finished (which was when the view refreshed).
So... I've moved all the logic about whether the card should stay face-up or flip over again into a separate function, called in a new thread. Brilliant. Almost works great (the card shows its face), but it doesn't quite. For some reason, it's failing on the line ((ImageView) gridview.getChildAt(mIntFirstCardID)).setImageResource (R.drawable.cardback); I've done some debug, and it's finding the gridview object fine, it's finding the child imageview fine, it's finding the drawable ID fine, but it's still bugging out with "...has stopped unexpectedly". Any ideas? Is there some weird property on setImageResource which means I can't call it outside the main thread? Anyone's help would be gratefully received... Thanks! On Aug 6, 12:32 pm, Saurav Mukherjee <[email protected]> wrote: > i got a hint of that while i was trying hard to get it. Thank you Mark for > the early reply. Just one more query, will it be the same if i set the > Background of the view or will it just depend on the invalidate() call? > > On Thu, Aug 6, 2009 at 4:55 PM, Mark Murphy <[email protected]> wrote: > > > Saurav Mukherjee wrote: > > > can anyone please tell me that does setImageResource() in ImageView also > > > draws the image instantly on the screen or does it require any other > > > function call? i need to display the image as soon as i set the resource. > > > The change will take effect as soon as you give control back to Android > > so it can continue processing the message loop. So, for example, if you > > call setImageResource() in the onClick() handler of a Button, the change > > will not take effect until sometime shortly after you return from > > onClick(). > > > -- > > Mark Murphy (a Commons Guy) > >http://commonsware.com|http://twitter.com/commonsguy > > > Need help for your Android OSS project?http://wiki.andmob.org/hado --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

