andriod CheckBox
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="多选控件:" android:id="@+id/label"/>
<CheckBox android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="AA" android:id="@+id/plain_cb"/>
<CheckBox android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="BB" android:id="@+id/serif_cb"/>
<CheckBox android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="CC" android:id="@+id/bold_cb"/>
<CheckBox android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="DD" android:id="@+id/italic_cb"/>
<Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="获取checkbox" android:id="@+id/button1"/>
</LinearLayout>
package com.example.yanlei.mytk; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
import android.widget.Toast; public class MainActivity extends AppCompatActivity { private CheckBox plainCB;
private CheckBox serifCB;
private CheckBox boldCB;
private CheckBox italicCB;
private Button button1;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); plainCB=(CheckBox)findViewById(R.id.plain_cb);
serifCB=(CheckBox)findViewById(R.id.serif_cb);
boldCB=(CheckBox)findViewById(R.id.bold_cb);
italicCB=(CheckBox)findViewById(R.id.italic_cb);
button1=(Button)findViewById(R.id.button1); button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String result="";
if(plainCB.isChecked()){
result+=plainCB.getText()+"、";
}
if(serifCB.isChecked()){
result+=serifCB.getText()+"、";
}
if(boldCB.isChecked()){
result+=boldCB.getText()+"、";
}
if(italicCB.isChecked()){
result+=italicCB.getText()+"、";
}
if(!"".equals(result)){
result=result.substring(0,result.length()-1);
}else{
result="你没有选择!!!";
}
setTitle("Checked:"+result);
}
}); }
}
andriod CheckBox的更多相关文章
- [译]在 Andriod/IOS 程序中使用自己的字体
原文链接:http://firemonkeyblog.blogspot.com/2014/12/using-custom-fonts-in-android-delphi.html 你应该能够在 And ...
- WPF CheckBox 样式
<Style x:Key="FocusVisual"> <Setter Property="Control.Template"> < ...
- 计算Div标签内Checkbox个数或已被disabled的个数
先看下面的html: 计算div内的checkbox个数:$('#divmod input[type="checkbox"]').length 计算div内checkbox被dis ...
- 前端开发:css技巧,如何设置select、radio 、 checkbox 、file这些不可直接设置的样式 。
前言: 都说程序员有三宝:人傻,钱多,死得早.博主身边的程序“猿”一大半应了这三宝,这从侧面说明了一个问题,只有理性是过不好日子的.朋友们应该把工作与生活分开,让生活变得感性,让工作变得理性,两者相提 ...
- Razor语法中绑定一个值给checkbox
在ASP.NET MVC开发中,需要绑定一个值给checkbox标签,如下面写法,它们运行时是没有问题,照样能跑. 看看上面的语法,在绑定时,它却出现绿浪线.提不绑定的值is not a valid ...
- Checkbox 模板和样式
<Style TargetType="{x:Type CheckBox}"> <Setter Property="FontFamily" Va ...
- Andriod 自定义控件之创建可以复用的组合控件
前面已学习了一种自定义控件的实现,是Andriod 自定义控件之音频条,还没学习的同学可以学习下,学习了的同学也要去温习下,一定要自己完全的掌握了,再继续学习,贪多嚼不烂可不是好的学习方法,我们争取学 ...
- RadioButton与CheckBox
笔者长期从事于数据库的开发,算了,不提当年了,因为一直用的是小语种(PowerBuilder),还是来说说这两个最常见的控件吧! RadioButton(单选)和CheckBox(多选) 先来看看继承 ...
- Listview的Item中有CheckBox、Button等的焦点处理
ListView的item布局中有CheckBox.Button等会获取焦点的控件会抢走焦点,造成ListView的item点击事件相应不了. 解决方法:控件设置 android:clickable= ...
随机推荐
- BZOJ 1001 [BeiJing2006] 狼抓兔子(平面图最大流)
题目大意 现在小朋友们最喜欢的"喜羊羊与灰太狼",话说灰太狼抓羊不到,但抓兔子还是比较在行的.而且现在的兔子还比较笨,它们只有两个窝,现在你做为狼王,面对下面这样一个网格的地形: ...
- Android 使用版本控制工具时添加忽略文件方式
一.使用SVN管理项目时,添加忽略文件的方式 Android Studio 配合SVN时,添加忽略文件相对简单,首先打开项目的Settings选项,切换到Version Control下的Ignore ...
- CM: 使用gerrit,提交代码到CM
1. Make sure your local git username matches with your Gerrit username, Gerrit username needs to be ...
- 当应用程序不是以 UserInteractive 模式运行时显示模式对话框或窗体是无效操作
在Web程序中引用了WinForm的类库引起了 主要是为了在web程序中使用Message.Show()以及SaveFileDialog类,能web程序中引用了WinForm类库 在Visual St ...
- undefined function mysql_connect()解决方法
在配置apache+php+mysql后,打开一个php网页文件正常,但是php网页中连接数据库时,出现以下提示: Fatal error: Call to undefined function my ...
- netbeans php安装、调试
文件清单 jdk-8u45-windows-i586_8.0.450.14.1429092020.exe netbeans-8.0.2-php-windows.exe wampserver2.5-Ap ...
- ServiceStack 介绍
关于ServiceStack ServiceStack 官网介绍: Opensource .NET and Mono REST Web Services framework 什么是 ServiceSt ...
- Cwinux简介及用法简述
我在我的个人博客上发表了一篇文章 Cwinux简介及用法简述 http://apprentice89.com/cwinux_introduction_and_use/
- Hadoop第5周练习—MapReduce计算气象温度等例子
:对云计算的看法 内容 :使用MapReduce求每年最低温度 内容 :求温度平均值能使用combiner吗? 内容 :使用Hadoop流求最高温度(awk脚本) 内容 :使用Hadoop流求最高温度 ...
- fork()函数详解
原文链接:http://blog.csdn.net/jason314/article/details/5640969 一.fork入门知识 一个进程,包括代码.数据和分配给进程的资源.fork()函 ...