views:

45

answers:

1

If I change one imageview's source to another (and thus changing the image) but then have more changes occur within the method and such. How do I force it to refresh to show the changes before the method ends? (As waiting for the method to end to show the changed images is not good for my purposes at all)

A: 

There's a Very Similar question that has an excellent answer (and a link to another similar question) right here.

Basically, unless you create a thread on your own, you're running in the UI thread. Invalidate/sleep just pauses rendering/input/etc. Your redraw() is only called in the UI thread after your current function exits. You want to separate the two, or use a lower-level technique (postInvalid() in another thread, or SurfaceView w/ repaint() respectively).

Mark Storer
hmmm I'm still somewhat confused though I feel like I'm approaching this whole project the wrong way -_- A thread is the Java Class that get's launched correct? I have a huge playscreen.java which is launched when the play button is pressed from another screen. This contains both the UI and the "game engine" So if I need to refresh.. i need to throw my "game engine" in another class.. that also get's launched when the UI get's launched and have the postInvalid() where needed upon each image or text change? Also what would go before the postInvalid and how would i launch both from the start
John V
It sounds like your "game engine" is running on the UI thread. This is very very bad
Falmarri
so my game engine should be in a different java class? How do I get the UI and game engine class running at the same time though?
John V
Mark Storer
Took a look at the first video and glanced through the second video. Seems like I need to throw things in threads? Now to learn threads heheh.
John V
(also meant to say thanks)
John V
Finally got the code working (performance could probably be better and whatnot.. but that's for another time : P) Ended up learning threads and using that.
John V
Damn It I keep hitting enter to go down a line.. not to add a comment.. ah well just wanted to thank you guys cause you really did help :D
John V