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 | 29 | 30 | 31 |
Tags
- Android
- AWT
- HTML
- Menu
- Graphic
- JavaScript
- 기본
- 예외처리
- OGNL
- 오버로딩
- oracle
- paint
- 클래스
- 배열
- struts2
- 어노테이션
- JSP
- 에러페이지
- 안드로이드
- layout
- 이클립스
- 전화걸기
- Java
- 메소드
- Spring
- mybatis
- 생성자
- 국제화
- 메서드
- Eclips
Archives
- Today
- Total
note
Android 체크 박스 본문
package com.commonsware.android.basic3;
//체크 박스
import android.app.Activity;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.CompoundButton;
public class CheckBoxDemo extends Activity implements CompoundButton.OnCheckedChangeListener{
CheckBox cb;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
cb =(CheckBox)findViewById(R.id.check);
//이벤트 소스와 이벤트 리스너가 구현된 객체 연결
cb.setOnCheckedChangeListener(this);
}
//이벤트 핸들러
//전달되는 인자
//CompoundButton buttonView : 이벤트가 발생한 CheckBox
//boolean isChecked : 체크박스가 선택되면 true
// 미선택되면 false
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked){
if(isChecked){
cb.setText("체크 상태");
}
else{
cb.setText("체크 하세유");
}
}
}
<?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" >
<CheckBox
android:id="@+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="체크하세유" />
</LinearLayout>
'Android > 기본' 카테고리의 다른 글
| Android Log Cat 사용 ,전화 걸기 문자 보내기 기능 (0) | 2012.01.06 |
|---|---|
| Android Radio Button (라디오 버튼) (0) | 2012.01.06 |
| Android 필드 박스 (0) | 2012.01.05 |
| Android 이미지 넣기 (0) | 2012.01.05 |
| Android 간단한 이벤트 3 (0) | 2012.01.05 |