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("체크되지 않은 상태");
}
}
}
}