I\'m trying to get my countdown app to perform its function of updating my current time and date TextView and fire off its MyOnItemSelectedListener every second so that the
Try to use UpdateDisplay function like below:
private void updateDisplay() {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
mHour = c.get(Calendar.HOUR_OF_DAY);
mMinute = c.get(Calendar.MINUTE);
mSecond = c.get(Calendar.SECOND);
cDateDisplay.setText(new StringBuilder()
// Month is 0 based so add 1
.append(mDay).append("/")
.append(mMonth + 1).append("/")
.append(mYear).append(" "));
cTimeDisplay.setText(
new StringBuilder()
.append(pad(mHour)).append(":")
.append(pad(mMinute)).append(":").append(pad(mSecond))
);
}
},0,1000);//Update text every second
}
Finally, you must to call updateDisplay() in onCreate() function.
I hope this code would help you finish what you want !