I have following timer:
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
--mTimer;
mTimeLeft.setText(String.valueOf(mTimer));
}
}, 0, 1000);
Text in the TextView will change when I touch the screen.
How can I refresh the TextView programatically?
I think this article will help you. http://android-developers.blogspot.com/2007/11/stitch-in-time.html
Basically you want to use the
Handlerclass provided in the SDK. You shouldn’t need to call invalidate like someone else suggested because setText does that for you.Hope this helps!