Toggle Buttons
来源:互联网 发布:降低音量软件 编辑:程序博客网 时间:2024/05/17 07:25
Toggle button给用户提供两选一的方案,例如on/off。只允许用户选择其中的一个.你可以直接在layout文件中添加一个Toggle button。
Toggle button 同样也是CompoundButton的子类,可以调用CompoundButton.setCheck() 或者CompoundButton.toggle()来自己改变Toggle button的状态。
在activity中要检测用户的点击事件,可以重写CompoundButton。OncheckeckListener方法来检测toggle button 是enable还是disable.
code 如下所示:
ToggleButton toggle = (ToggleButton) findViewById(R.id.togglebutton);
toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
// The toggle is enabled
} else {
// The toggle is disabled
}
}
});
先通过findViewById 找到ToggleButton,然后重写onCheckedChanged,通过形参的第二个参数boolean isChecked来判断togglebutton是enable还是disable.
Toggle button 同样也是CompoundButton的子类,可以调用CompoundButton.setCheck() 或者CompoundButton.toggle()来自己改变Toggle button的状态。
在activity中要检测用户的点击事件,可以重写CompoundButton。OncheckeckListener方法来检测toggle button 是enable还是disable.
code 如下所示:
ToggleButton toggle = (ToggleButton) findViewById(R.id.togglebutton);
toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
// The toggle is enabled
} else {
// The toggle is disabled
}
}
});
先通过findViewById 找到ToggleButton,然后重写onCheckedChanged,通过形参的第二个参数boolean isChecked来判断togglebutton是enable还是disable.
0 0
- Toggle Buttons
- Toggle Buttons
- 风格化的 Toggle Buttons
- 风格化的 Toggle Buttons
- 风格化的 Toggle Buttons
- Toggle Buttons(开关按钮)
- Android API Guides---Toggle Buttons
- 常用控件 06 开关按钮 Toggle Buttons
- Toggle Buttons(SwitchButton),开关按钮
- 开关按钮 Toggle Buttons@GTK+ 2.0 中文教程连载
- How To Create Buttons in Cocos2D: Simple, Radio, and Toggle
- Buttons
- toggle()
- jquerymobile-7 表单基础 radio buttons和checkboxes select menu 搜索框、滑动按钮(Slider)、开关(Flip toggle switch)
- ExtJS buttons
- B. Buttons
- poj2368 Buttons
- POJ2368 Buttons
- Android 屏蔽/禁止ListView,GridView的滑动/滚动功能
- 《Motion Design for iOS》(四十)
- Dialog、Toast、Snackbar的区别和使用
- 实时错误‘-2147217873(80040e2f)’
- GitHub Ant-Design/ant-init 使用示例
- Toggle Buttons
- Thrift入门
- git log退出方法
- Java连接Oracle数据库
- 算法竞赛入门经典——骰子上色
- openGL6大坐标系
- 给未来程序员的15个顶级职业建议
- 100天土鸡饲养计划(23)
- centos eclipse创建web 项目