안드로이드의 Ui 는 전용 Thread 로!

Android 2015. 2. 6. 15:00

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


요런 error 메시지가 나와서 보니

안드로이드에서 View를 처리할 때 Uithread를 통하지 않으면 예외가 발생하는 듯 하다.


UiThread 를 통해 처리하니 문제 없이 됨.

timerTask = new TimerTask(){

@Override

public void run() {

// UI Thread를 사용해서 View 를 처리합니다.

runOnUiThread(new Runnable(){

@Override

public void run(){

try{

resetAnimation();

}catch(Exception e){

e.printStackTrace();

}

}

});

}

};



참고 ; http://beastlair.tistory.com/82




: