Android第八课;CheckBox
来源:互联网 发布:hbase java api 编辑:程序博客网 时间:2024/05/16 10:57
preview
CheckBox就是复选框
两种状态:被选中(true),未被选中(false)
属性:android:checked=”false”——–决定它被选中与否
exercise
实现点击一个CheckBox后屏幕会显示该CheckBox的文字内容
layout
<!--默认android:checked="false",当然也可以写android:checked="true"进去,这样 Box刚开始就是被选中的状态--> <CheckBox android:text="CheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/checkBox" />
Activity
public class MainActivity extends AppCompatActivity { private CheckBox ckBox; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ckBox= (CheckBox) findViewById(R.id.checkBox); ckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) {//通过onCheckedChanged来监听CheckBox是否被选中,并把被选中的Box的文字信息显示出来 if(b){ String text=ckBox.getText().toString(); //被点中时显示CheckBox的文字内容 Toast.makeText(MainActivity.this,text,Toast.LENGTH_SHORT).show(); } } }); }}
0 0
- Android第八课;CheckBox
- Android第八课--数据共享
- Android CheckBox
- Android CheckBox
- Android CheckBox
- Android-CheckBox
- Android开发 第八课 布局 LinearLayout
- android应用程序第8课:CheckBox
- Android基础第八篇
- CheckBox---Android控件系列之CheckBox
- Android 之 CheckBox
- android之CheckBox
- android checkbox多选框实现
- android checkbox样式
- android listview checkbox
- android CheckBox 自定义样式
- android checkbox样式
- android widget 之CheckBox
- 一个基于HTML5的虚拟实验室
- 面试求职信息整理
- 电脑极限的数组
- 小程序正式发布前调整服务范围,扩展直播、社交等多项服务领域
- 191. Number of 1 Bits 难度:easy
- Android第八课;CheckBox
- C# USB通信(调用Windows API)
- 使用pymssql进行中文操作时候可能会出现中文乱码
- 有关java中对象序列化与反序列化的乱码问题
- 12-Oracle入门之集合运算
- 苹果地图使用之MKMapView定位显示
- poj 2947 Widget Factory (高斯消元)
- 大话数据机构读书笔记(一)-基本概念
- ubuntu下caffe的FCN8模型训练