android, UI, timer, timer with UI 計時器裡面要控制UI 的資料

Updating the UI from a Timer

public class myActivity extends Activity {

	private Timer myTimer;

	/** Called when the activity is first created. */
	public void onCreate(Bundle icicle) {

		myTimer = new Timer();
		myTimer.schedule(new TimerTask() {
			public void run() {

		}, 0, 1000);

	private void TimerMethod()
		//This method is called directly by the timer
		//and runs in the same thread as the timer.

		//We call the method that will work with the UI
		//through the runOnUiThread method.

	private Runnable Timer_Tick = new Runnable() {
		public void run() {

		//This method runs in the same thread as the UI.    	       

		//Do something to the UI thread here


CH01 簡介篇CH02 開發設定CH03 Android 軟體評論CH04 UICH05Android studioCH09 資料庫databaseCH10 系統篇CH11 多執行序和時間 ThreadTimerCH29 APICH30 Android 技術文章CH50 Android IOIO