Android

[Android] Only the original thread that created a view hierarchy can touch its views

여행하는 개발자 2021. 10. 25. 17:54

문제원인: Non-UI Thread에서 UI 관련 작업을 할 때 발생하는 오류이다.

 

 

해결방법: UI Thread를 이용하여 UI 관련 작업을 한다.

 

if (Looper.myLooper() != Looper.getMainLooper()) {
    mContext.runOnUiThread(() -> {
        // UI 관련작업을 수행한다
    });
}