2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > only the original thread that created a view hierarchy can touch its views解决方案

only the original thread that created a view hierarchy can touch its views解决方案

时间:2021-11-18 01:44:34

相关推荐

only the original thread that created a view hierarchy can touch its views解决方案

Caused by: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.

此错误是在非UI线程中更新UI所造成的,解决方案如下:(注:在需要更新UI的地方调用new LongTimeTask().execute("此处为任意字符或空均可");)

private class LongTimeTask extends AsyncTask<String, Void, String> {@Overrideprotected String doInBackground(String... params) {return params[0];}@Overrideprotected void onPostExecute(String result) {//更新UI的操作,这里面的内容是在UI线程里面执行的}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。