private class GameThread implements Runnable{
public void run() {
while (!Thread.currentThread().isInterrupted()) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
//使用postInvalidate可以直接在线程中更新界面
tv_dingdanshuliang.postInvalidate();
}
}
}
// 在onCreate()中开启线程
new Thread(new GameThread()).start();
public void run() {
while (!Thread.currentThread().isInterrupted()) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
//使用postInvalidate可以直接在线程中更新界面
tv_dingdanshuliang.postInvalidate();
}
}
}
// 在onCreate()中开启线程
new Thread(new GameThread()).start();