使用CheckBox实现多选效果
来源:互联网 发布:拜占庭将军问题 算法 编辑:程序博客网 时间:2024/06/08 20:37
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" > <CheckBox android:id="@+id/checkBox1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="篮球" /></LinearLayout>
package com.demo2.demo2;import android.app.Activity;import android.os.Bundle;import android.util.Log;import android.widget.CheckBox;import android.widget.CompoundButton;import android.widget.CompoundButton.OnCheckedChangeListener;public class MainActivity extends Activity{private CheckBox checkBox;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);//初始化checkBoxcheckBox=(CheckBox)findViewById(R.id.checkBox1);//通过设置checkBox的监听事件来对checkBox是不是被选中checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {@Overridepublic void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {Log.i("tag", isChecked+"");//通过这个onCheckedChanged方法来监听当前的checkBox是否被选中if(isChecked){//获得checkBox的文本内容String text=checkBox.getText().toString();Log.i("tag", text);//打印输出}}});}}
0 0
- 使用CheckBox实现多选效果
- 使用checkbox实现单选效果 (模拟radio)
- 使用CheckBox控件实现同意条款效果
- 使用 jquery 实现 checkbox “全选/全不选” 效果
- ListView + CheckBox实现单选、多选效果
- checkbox实现单选按钮效果
- input:checkbox多选框实现单选效果
- checkbox 实现单选效果(html)
- 用CheckBox实现ListView单选效果
- ListView+CheckBox实现单选效果
- checkbox多选框实现单选效果
- RecyclerView之CheckBox实现单选效果
- ListView 中使用CheckBox实现多选
- GridView实现checkbox效果(单选效果)
- 使用系统自带CheckBox实现单选效果的2个线性布局切换
- checkbox 实现多选
- iOS 快速实现Checkbox 效果
- jQuery 实现checkBox全选效果
- Android View体系(一)视图坐标系
- ELK_Elastic Search和kibana版本对应关系
- Android使用CircleImageView实现圆形头像的方法
- 一点感悟
- 软件工程(C语言实践篇)学习心得总结
- 使用CheckBox实现多选效果
- 你的自娱自乐与我无关,希望你知道
- Netty初探
- wamp-MySQL创建用户与授权方法
- JavaScript快速上手之11:表单验证
- android初级学习之深入了解View绘制流程(一)
- 布局优化技巧
- CentOS 6.5下Redis安装详细步骤
- oracle数据泵导入错误:ORA-39082:Object type ALTER_PACKAGE_SPEC:""create with compilation warnings