Hi Mark, I am back. I forgot this thread here. using your suggestion, i choose using AsyncTask and implement onPostExecute(). Iam very happy It works well. but I write an inner class that extends AsyncTash to use findViewById. can i wirte a non-inner class to get the TextView to setText()?
On Sat, Dec 18, 2010 at 9:37 PM, Mark Murphy <[email protected]>wrote: > On Sat, Dec 18, 2010 at 8:26 AM, goodwin <[email protected]> wrote: > > 12-18 21:09:15.104: ERROR/AndroidRuntime(4368): > > android.view.ViewRoot$CalledFromWrongThreadException: Only the original > > thread that created a view hierarchy can touch its views. > > i am using google translate api to practice.when i write a new thread,and > > use setText() in this thread, error turn out.where i can set text to > > TextView. > > You cannot modify the UI from a background thread. Consider converting > your Thread to an AsyncTask and modifying the UI from onPostExecute(). > Or, use a Handler. Or, call post() on your TextView. Or, call > runOnUiThread() on your activity. > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://github.com/commonsguy > http://commonsware.com/blog | http://twitter.com/commonsguy > > _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 > Available! > > -- > 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]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- 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

