无与伦比的猪 2020-09-25 15:29 采纳率: 100%
浏览 1877
已采纳

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

  • 写回答

1条回答 默认 最新

  • 中控易动 企业官方账号 2020-09-25 15:52
    关注

    android中相关的view和控件不是线程安全的,我们必须单独做处理。
    处理方法:

    private static final Handler handler = new Handler(Looper.getMainLooper());
    
          handler.post(new Runnable() {
                @Override
                public void run() {
                    //代码逻辑
                }
            });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?