I have a textview that displays a timer, and i use string.format so the seconds will always use 2 digits: 0:00
But when i hit 10 minutes(the minutes also goes up to two digits) the seconds only uses one digit instead of two.
The timerRunnable:
Runnable timerRunnable = new Runnable() {
@Override
public void run() {
millis = System.currentTimeMillis() - startTime;
aSeconds = (int) (millis / 1000) + paSeconds;
seconds = (int) (millis / 1000) + pSeconds;
minutes = seconds / 60 + pMinutes;
seconds = seconds % 60;
timerTextView.setText(String.format("%d:%02d", minutes, seconds));
if(aSeconds == delay){
Toast.makeText(getApplicationContext(), "Drink",
Toast.LENGTH_LONG).show();
delay += delay;
count += 1;
Log.d("MainActivity", "" + count);
}
timerHandler.postDelayed(this, 1000);
}
};
I'm pretty sute the problem is that I set the String.format to basically only include 3 digits combined, but i can't find a clever solution to the problem
The solution was simply to just make my textview smaller when the timer hits 10 minutes, it just wasn't showing on the screen..