On Thu, Jun 30, 2011 at 5:46 AM, BlackBishop64
<[email protected]> wrote:
> I have the following problem:  in my main activity I've created a
> linearlayout vertical with 3 views, a title view, a game view and a
> score view. Game view is update with a thread in order to keep a
> constant framerate, this thread call the method onDraw of the game
> view, so far so good, the problem appears when just after calling
> onDraw of the gameView I make a setText in the ScoreView (kind of
> TextView), then a CalledFromWrongThreadException appears saying: "Only
> the original thread that created a view hierarchy can touch its
> views."
>
> Can I not have a single thread for updating all the views?
> What can I do?

Use runOnUiThread(), or post(), or a Handler -- all of these will
route your setText() call to the main application thread.

Or, don't use TextView, but draw the text yourself, the way you are
drawing everything else yourself.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training in London: http://bit.ly/smand1, http://bit.ly/smand2

-- 
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

Reply via email to