方法一
Timer与TimerTask(Java实现)
public class timerTask extends Activity{ private int recLen = 11; private TextView txtView; Timer timer = new Timer(); public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.timertask); txtView = (TextView)findViewById(R.id.txttime); timer.schedule(task, 1000, 1000); // timeTask } TimerTask task = new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { // UI thread @Override public void run() { recLen--; txtView.setText(""+recLen); if(recLen < 0){ timer.cancel(); txtView.setVisibility(View.GONE); } } }); } }; }