How to display a timer in a TextView in Android?
问题 I want to set this textview: <TextView android:id="@+id/timer" android:layout_width="100dp" android:layout_height="30dp" android:layout_above="@+id/directions"/> To be a timer. So the text should be a timer going like 0:30 then 0:29 ... for 30 seconds. Once timer is 0:00, I can call another method; I can print out "try again" and restart timer. 回答1: int time=30; TextView textTimer = (TextView)findViewById(R.id.timer); new CountDownTimer(30000, 1000) { public void onTick(long