我试图将我的问题放在下面的伪代码中:
public class something extends Activity {
// some buttons and text view declaration
public TextView textViewSomethingStatus;
on create() {
textViewSomethingStatus = (TextView) findViewById(R.id.something);
//Here at one point i have stated thread
new specialThread().start();
}
// some methods
class specialThreads extends Thread {
public void run() {
//after performing some task.
textViewSomethingStatus.setText("hello world");//This gives me crash
}
}
}
当我想从另一个类更新文本框中的文本时,我遇到了崩溃。我该怎么做呢?与在 Java 中一样,我们不能扩展多个类。
编辑 :
E/AndroidRuntime(605): android.view.ViewRootImpl$CalledFromWrongThreadException: 只有创建视图层次结构的原始线程才能触摸它的视图。