想通过txtSec显示从60秒倒数到0的效果,请问下面的代码有什么问题?
public class Activity2 extends Activity {
private int Sec;
private TextView txtSec;
private TextView txtview1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity2);
Sec=60;
txtSec=(TextView) this.findViewById(R.id.txtSec);
handler.post(updateThread);
}
Handler handler=new Handler();
Runnable updateThread=new Runnable(){
public void run(){
Sec--;
txtSec.setText(Sec);
if (Sec>0){
handler.postDelayed(updateThread, 1000);
}else{
handler.removeCallbacks(updateThread);
}
}
};
}
------解决方案--------------------
看下logCat信息报什么错