08-18 11:24:09.503: ERROR/AndroidRuntime(22649): Caused by: android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarch开发者_开发问答y can touch its views.
Is there any solution? :/
Yes.
You can't touch UI in non-UI threads, so the solution is to run the problematic code inside a runOnUiThread
:
runOnUiThread(new Runnable() {
public void run() {
//your problematic code
}
});
Only the UI thread can manipulate with views and stuffs. If you are working in another thread, try using Handler
to post change to view to UI thread or switch to use AsyncTask
So you are using AsyncTask
already, so you should ProgressBar.setProgress()
inside onProgressUpdate()
of AsyncTask
. Override this method
精彩评论