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= ...
随机推荐
- Qt5 从头学(1)-- 环境
对我来说MFC太过麻烦了,同样是桌面开发工具,Qt就完全不一样了.Qt使用C++语言可以轻松实现"一次编写,到处编译"的跨平台性能,并且可以做出很多炫酷的界面效果.目前支持几乎所有 ...
- HMM 自学教程(八)总结
本系列文章摘自 52nlp(我爱自然语言处理: http://www.52nlp.cn/),原文链接在HMM 学习最佳范例,这是针对国外网站上一个 HMM 教程的翻译,作者功底很深,翻译得很精彩,且在 ...
- Java魔法堂:以Windows服务的形式运行Java程序
一.前言 由于防止维护人员误操作关闭Java控制台程序,因此决定将其改造为以Windows服务的形式运行.弄了一个上午总算搞定了,下面记录下来,以供日后查阅. 二.Java Service Wrapp ...
- GPUImage滤镜之自然饱和度
自然饱和度”是图像整体的明亮程度,“饱和度”是图像颜色的鲜艳程度. “饱和度”与“色相/饱和度”命令中的“饱和度”选项效果相同,可以增加整个画面的“饱和度”,但如调节到较高数值,图像会产生色彩过饱和从 ...
- adaboost原理和实现
上两篇说了决策树到集成学习的大概,这节我们通过adaboost来具体了解一下集成学习的简单做法. 集成学习有bagging和boosting两种不同的思路,bagging的代表是随机森林,boosti ...
- 安装DRBD的一些问题
安装DRBD,建议用源代码包先生成rpm包来安装,不要用直接download的rpm包,有可能会用不了,因为这跟系统内核版本有关系,在2.6.33版本以前内核没有集成drbd, A.先安装一些其它 ...
- Gradle学习系列之五——自定义Property
在本系列的上篇文章中,我们讲到了增量式构建,在本篇文章中,我们将讲到如何自定义Project的Property. 请通过以下方式下载本系列文章的Github示例代码: git clone https: ...
- Mysql的“Limit”操作
Limit操作: ,; #返回第6-15行数据 ; #返回前5行 ,; #返回前5行 性能优化: 基于MySQL5.0中limit的高性能,我对数据分页也重新有了新的认识.测试SQL语句1: Sele ...
- LeetCode - 38. Count and Say
38. Count and Say Problem's Link ------------------------------------------------------------------- ...
- 使用HtmlAgilityPack爬取网站信息并存储到mysql
前言:打算做一个药材价格查询的功能,但刚开始一点数据都没有靠自己找信息录入的话很麻烦的,所以只有先到其它网站抓取存到数据库再开始做这个了. HtmlAgilityPack在c#里应该很多人用吧,简单又 ...