Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- layout
- 메소드
- Java
- 전화걸기
- 기본
- 클래스
- 어노테이션
- 오버로딩
- 예외처리
- OGNL
- Android
- 안드로이드
- 에러페이지
- JavaScript
- Eclips
- JSP
- 국제화
- 배열
- Graphic
- 생성자
- HTML
- Menu
- mybatis
- 메서드
- 이클립스
- struts2
- Spring
- AWT
- oracle
- paint
Archives
- Today
- Total
note
Android 간단한 이벤트 3 본문
package com.commonsware.android.skeleton3;
import java.util.Date;
import java.text.SimpleDateFormat;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import java.util.Date;
public class NowRedux2 extends Activity{
Button btn;
SimpleDateFormat sf = new SimpleDateFormat("yyyy년 mm월 dd일 a HH:mm:ss");
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//main.xml 등록
setContentView(R.layout.main);
//button 객체 호출(이벤트 소스)
btn=(Button)findViewById(R.id.button);
//이벤트 소스와 이벤트 리스너가 구현된 객체를 연결
//익명 내부 클래스 형태의 이벤트 처리
btn.setOnClickListener(new View.OnClickListener() {
//이벤트 핸들러
public void onClick(View view){
updateTime();
}
});
updateTime();
}
private void updateTime(){
btn.setText(sf.format(new Date()));
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
'Android > 기본' 카테고리의 다른 글
| Android 필드 박스 (0) | 2012.01.05 |
|---|---|
| Android 이미지 넣기 (0) | 2012.01.05 |
| Android 간단한 이벤트2 (0) | 2012.01.05 |
| Android 간단한 이벤트 (0) | 2012.01.05 |
| android 기본 (0) | 2012.01.05 |