我有以下启动一个线程,当活动开始
public class StartGameActivity extends BaseActivity {
public TextView txtCustomerCount;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.start_game);
this.txtCustomerCount = (TextView) findViewById(R.id.txtCustomerCount);
testThread();
}
public void testThread(){
Runnable runnable = new Runnable() {
@Override
public void run() {
int count = 0;
boolean stop = false;
while(!stop){
txtCustomerCount.setText(Integer.toString(count));
fakework(2000);
count++;
if(count > 99){
stop = true;
}
}
}
};
new Thread(runnable).start();
}
public void fakework(int lasts){
try {
Thread.sleep(lasts);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
现在
下面的代码是什么我想在这里是启动一个线程执行onCreate()
但上面的代码返回这样
错误07-10 17:20:20.046:E/AndroidRuntime(6216): android.app.SuperNotCalledException:活动 {yens.alisa.menu/yens.alisa.menu.StartGameActivity}没有调用 通过超。 onStart()
我哪里出错了?如果你可以请进一步解释,因为我刚刚开始学习android。谢谢。
您是否添加了onStart()? –
Stacktrace显然与问题没有关系:(因为我没有阅读明确的错误信息downvoted – C4stor
@ C4stor,这只是显示的错误日志,你可能想要一个截图作为证据吗? –