Runnable
[언어] Android 2015. 2. 20. 14:55package kr.co.kimjaehyun.bundlekit.stopwatch;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class Main extends Activity {
Button btnReset = null;
Button btnRun = null;
Button btnMark = null;
TextView txtTime = null;
TextView txtTimgSave= null;
Handler mhand = null;
Runnable mUpdateTimeTask = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnReset = (Button) findViewById(R.id.btn_reset);
btnRun = (Button) findViewById(R.id.btn_run);
btnMark = (Button) findViewById(R.id.btn_mark);
btnReset.setOnClickListener(btnClick);
btnRun.setOnClickListener(btnClick);
btnMark.setOnClickListener(btnClick);
mhand = new Handler();
mUpdateTimeTask = new Runnable() {
public void run() {
long l = System.currentTimeMillis();
Log.d("DEV","Log : "+l);
mhand.postDelayed(mUpdateTimeTask, 10);
}
};
}
Button.OnClickListener btnClick = new View.OnClickListener() {
public void onClick(View v){
if( v.getId() == R.id.btn_run ){
mhand.removeCallbacks(mUpdateTimeTask);
mhand.postDelayed(mUpdateTimeTask, 100);
}else if( v.getId() == R.id.btn_reset ){
mhand.removeCallbacks(mUpdateTimeTask);
}else if( v.getId() == R.id.btn_mark ){
}
}
};
}
'[언어] Android' 카테고리의 다른 글
android 책장 효과 (0) | 2015.02.20 |
---|---|
스마트폰 패킷 감청 (0) | 2015.02.20 |
스크린크기에 따른 밀도 계산 : 픽셀 = dip * (밀도/160) (0) | 2015.02.20 |
ringdroid (0) | 2015.02.20 |
마켓 주소 (0) | 2015.02.20 |