我只是一个初学者所以请原谅我提出可能是一个愚蠢的问题
我不明白只有创建视图层次结构的原始线程才能触及其视图.
请有人教我这个错误发生的原因以及如何解决这个问题.
谢谢
这是我的班级
public class MainActivity extends Activity {
TextView title;
Random random = new Random();
int counter = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.startup);
startingUp();
}
private void startingUp() {
Thread timer = new Thread() { //new thread
public void run() {
Boolean b = true;
try {
do {
counter++;
title();
sleep(1000);
title.clearComposingText();
}
while (b == true);
} catch (IntruptedException e) {
e.printStackTrace();
}
finally {
}
};
};
timer.start();
}
public …Run Code Online (Sandbox Code Playgroud)