Andriod Checkbox
来源:互联网 发布:淘宝关键词竞争指数 编辑:程序博客网 时间:2024/06/18 08:23
1、在xml添加布局代码:
<CheckBox android:id="@+id/checkbox1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:text="checkbox1" android:onClick="onCheckboxClicked" /> <CheckBox android:id="@+id/checkbox2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="70dp" android:text="checkbox2" android:onClick="onCheckboxClicked" />
2、在MainActivity.java中添加点击事件:
public void onCheckboxClicked(View view) { boolean checked = ((CheckBox) view).isChecked(); switch (view.getId()) { case R.id.checkbox1: if (checked) { Toast.makeText(MainActivity.this,"checkbox被选中",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(MainActivity.this,"checkbox没有选中",Toast.LENGTH_SHORT).show(); } break; case R.id.checkbox2: if (checked) { Toast.makeText(MainActivity.this,"checkbox2被选中",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(MainActivity.this,"checkbox2没有被选中",Toast.LENGTH_SHORT).show(); } break; } }
0 0
- Andriod Checkbox
- andriod
- andriod
- Andriod
- andriod
- andriod
- Andriod
- Andriod
- Andriod
- andriod中checkbox图标的修改、textView(editText)周围图标的位置设置
- andriod开发点滴(在listView上添加了一个checkbox后,点击list无响应)
- checkbox
- checkbox
- CheckBox
- CheckBox
- checkbox
- checkbox
- checkbox
- hdu——1010Tempter of the Bone
- leetcode-23-Merge k Sorted Lists
- 建造者设计模式
- ORACLE报错
- PyCharm使用(二)
- Andriod Checkbox
- 使用js实现上移、下移、置顶、置底功能及源码案例
- HDU 4391 Paint The Wall
- 【c++】第十二周上机实践作业 项目 1-2
- Python中tile函数的用法
- 贝塞尔曲线在Android中的应用
- CSS选择器总结
- 服务器上的Mysql表全丢了情况下恢复数据
- R语言入门