내 스레드에서 textView를 변경하려고하지만 항상 충돌합니다. 왜?스레드에서 TextView 텍스트를 변경할 수 없습니다.
public void startProgress(View view) {
bar.setProgress(0);
new Thread(new Task()).start();
}
class Task implements Runnable {
@Override
public void run() {
for (int i = 0; i <= 10; i++) {
final int value = i;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
bar.setProgress(value);
text.setText("i = "+i);
}
}
}
나는 왜 내가 그것을 바꿀 수 있는지 모른다. 왜 그 사람이 누군지 압니까?
감사합니다.
몇 가지 상황 (예 : 'ProgressBar')을 제외하고는 백그라운드 스레드에서 활동 또는 프래그먼트의 UI를 수정할 수 없습니다. – CommonsWare