我创造了这个应用程序,现在我想用一个TextView来显示秒,直到其他活动开始,但我不知道怎么回事,我创建了一个txtview的countdowntimer内,但它从来没有表现出Countdowntimer的TextView
Event=new String(Edt.getText().toString());
final int time = Integer.parseInt(sec.getText().toString());
Intent myInt = new Intent(MainActivity.this,Receiver.class);
myInt.putExtra("key",Event);
endingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this,2,myInt,PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+(time*1000),pendingIntent);
new CountDownTimer(time*1000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
// TODO Auto-generated method stub
txtV.setText("Activity starts"+millisUntilFinished/1000+"seconds"); // here is the txtV which isn't shown
}
@Override
public void onFinish() {
// TODO Auto-generated method stub
}
};
如何启动一个'CountDownTimer'? – 2013-03-25 13:11:01