其中timer是textview并在运行时抛出错误。
[Getting MAX_TEXTURE_SIZE from GradienCache]
[Getting MAX_TEXTURE_SIZE from Caches::initConstraints()]
Plz帮助.-------------------------------------------- -------------------------------------------------- -------
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.level_twolayout);
t1 = new Thread() {
public void run() {
for (int i = 50; i>= 0; i--) {
try {
error------> Timer.setText(i);
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};t1.start();
}
[1]: http://i.stack.imgur.com/p9XCY.png
答案 0 :(得分:0)
试试这个:
TextView Timer;
int i ;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player);
Timer = (TextView)findViewById(R.id.textView1);
final int length = 50;
Thread t = new Thread(new Runnable() {
@Override
public void run() {
for ( i = 0; i < length; i++) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Timer.setText(new Integer(i).toString());
}
});
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});
t.start();
}