PowenKo, Android, Tutorial 080-1, Thread, Timer clock

August 24, 2011   ·   0 Comments

Timer clock


package com.powenko.Tutorial_thread_Timer;




import android.app.Activity;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.widget.TextView;

public class Tutorial_thread_TimerActivity extends Activity {
	// Created by PowenKo.com on 2011/2/23.
	private TextView mTextView1;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mTextView1=(TextView)findViewById(R.id.textView1);
        
        MyCount counter = new MyCount(60000,1000);
       

        counter.start();
    }
    ////////
    public class MyCount extends CountDownTimer{
    	public MyCount(long millisInFuture, long countDownInterval) {
    	super(millisInFuture, countDownInterval);
    	}
    	@Override
    	 public void onTick(long millisUntilFinished) {
        	mTextView1.setText("PowenKo Clock:\n seconds remaining: " + millisUntilFinished / 1000);
        }

        public void onFinish() {
        	mTextView1.setText("PowenKo Clock:\n  done!");
        }
    }
    	
}

res\layout\main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
android:id="@+id/textView1"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />


</LinearLayout>



sample code:

Tutorial_thread_Timer

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Android7

Amazon

adsbygoogle

Recent Posts

Categories

Amazon