android控件checkBox的选中效果
来源:互联网 发布:java三年工作经验工资 编辑:程序博客网 时间:2024/06/05 02:07
一如既往的先声明:
private TextView result; private String china;
接下来:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); result= (TextView) this.findViewById(R.id.result);//获取TextView CheckBox checkBox= (CheckBox) this.findViewById(R.id.checkBox);//获取CheckBox checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {//选中事件 if(isChecked) { china= (String) buttonView.getText(); }else china=""; result.setText("你最喜欢的美食是:"+china); } }); }
以下是xml的代码:
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="你最喜欢吃的菜是什么" android:id="@+id/textView" /> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="中餐" android:id="@+id/checkBox" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="你最喜欢的美食是:" android:id="@+id/result" />
在这里我只写了一个checkBox,可以写多几个可以更好体现checkBox控件效果。
如果有错,欢迎评论指正,学习至上!
更多文章:http://blog.csdn.net/qq_26849491
0 0
- android控件checkBox的选中效果
- Android ListView 选中控件效果
- android checkBox 的选中和取消选中
- Android的CheckBox控件的点击效果布局文件
- jquery checkbox选中效果
- 【项目】TreeView控件的CheckBox选中事件
- post未选中的checkbox控件
- Android 中如何处理checkbox的选中、未选中
- RadioButton、CheckBox去除选中时的动画阴影效果
- Android checkbox默认选中
- MFC CheckBox控件选中或取消选中
- 遍历一个容器的控件,统计选中的checkbox
- 代码控制CheckBox或者其他控件的选中状态
- 保存Repeater控件中input CheckBox的选中状态
- CheckBox 选中效果 选中子自动选中父
- CheckBox或RadioButton自定义选中/非选中效果的注意点
- radio,checkbox的选中
- checkbox选中的问题
- hdu1671(Tire-Tree)
- 动力效果 UIGravityBehavior- UICollisionBehavior- UIDynamicItemBehavior
- POJ 1503 Integer Inquiry 美丽的大整数相加 + 测试数据
- 判断一个数组是否是一棵树的后续遍历
- 事务1
- android控件checkBox的选中效果
- Java Comparator 排序
- 【解决方法】Setup script exited with error: command 'cc' failed with exit status 1
- HTTP协议详解(真的很经典)
- HTML学习记录<一>:<abbr>及<acronym>
- matlab中sum函数对矩阵的求和总结
- C# Task类 笔记
- Linux守护进程设计规范及python实现http://blog.csdn.net/dysj4099/article/details/18219411
- 黑马程序员——面向对象之异常(二)