Android 控件(View)之 TextView Button ImageButton ImageView CheckBox
2010-02-27 23:48:00 来源:WEB开发网
_CheckBox.java
代码
package com.webabcd.view;
import android.app.Activity;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
public class _CheckBox extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.setContentView(R.layout.checkbox);
setTitle("CheckBox");
CheckBox chk = (CheckBox) this.findViewById(R.id.chk1);
// setOnCheckedChangeListener() - 响应复选框的选中状态改变事件
chk.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
TextView txt = (TextView) _CheckBox.this.findViewById(R.id.textView);
txt.setText("CheckBox01 的选中状态:" + String.valueOf(isChecked));
}
});
}
}
6、RadioButton 的 Demo
radiobutton.xml
更多精彩
赞助商链接