我在下面有以下代码
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(6247): android.app.SuperNotCalledException: Activity {yens.alisa.menu/yens.alisa.menu.StartGameActivity} 没有调用到 super.onStart()
我哪里出错了?如果您可以进一步解释,因为我刚刚开始学习android。谢谢你。