W.A 저장소

Android CheckBox 본문

Programing

Android CheckBox

W.A 2010. 7. 20. 11:16
package com.karyu.androidstudy;

import android.app.Activity;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;

public class AndroidStudyActivity extends Activity {
CheckBox cb;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        cb = (CheckBox)findViewById(R.id.check);
        cb.setOnCheckedChangeListener(new CheckBoxListener());
    }
    
    private class CheckBoxListener implements OnCheckedChangeListener {

@Override
public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
// TODO Auto-generated method stub
if(arg1) {
arg0.setText("체크 상태");
}else {
arg0.setText("체크되지 않은 상태");
}
}
    }
}

'Programing' 카테고리의 다른 글

Android Database(Sqlite) Instruction  (2) 2010.07.29
Android Spinner  (0) 2010.07.20
Programming Reference  (0) 2010.07.16
Screen Capture Class(화면 캡쳐 클래스) Robot  (0) 2010.07.16
AccelerorMeter Sensor 사용 소스  (0) 2010.07.15