main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<CheckBox
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/sportsCheckBox"
android:text="@string/sportsTxt"
/>
<CheckBox
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/movieCheckBox"
android:text="@string/movieTxt"
/>
</LinearLayout>
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">爱好选择</string>
<string name="app_name">CheckBox</string>
<string name="sportsTxt">体育</string>
<string name="movieTxt">电影</string>
</resources>
CheckBoxActivity.java
package com.qianlong.activity;
import android.app.Activity;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.Toast;
import android.widget.CompoundButton.OnCheckedChangeListener;
public class CheckBoxActivity extends Activity {
private CheckBox sportsCheckBox;
private CheckBox movieCheckBox;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.sportsCheckBox = (CheckBox) this.findViewById(R.id.sportsCheckBox);
this.movieCheckBox = (CheckBox) this.findViewById(R.id.movieCheckBox);
this.sportsCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked) {
Toast.makeText(CheckBoxActivity.this, "您选择了体育!", Toast.LENGTH_SHORT).show();
}
}
});
this.movieCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked) {
Toast.makeText(CheckBoxActivity.this, "您选择了电影!", Toast.LENGTH_SHORT).show();
}
}
});
}
}
分享到:
相关推荐
C#_winform_GridView_CheckBox_多选_全选
完整版模块_CHECKBOX.rar
学习文档__checkbox c# 用于开发人员进行学习
C#_winform_DataGridView_checkbox复选框_实现单选效果
Ext_Net_CheckboxGroup 勾选、全选、反选和限制勾选
完整版模块_CHECKBOX.e.rar
易语言源码模块_CHECKBOX.zip
m_ToolBar.SetButtonStyle(0,TBBS_CHECKBOX); m_ToolBar.SetButtonStyle(1,TBBS_CHECKBOX); m_ToolBar.SetButtonStyle(2,TBBS_CHECKBOX); m_ToolBar.SetButtonStyle(3,TBBS_CHECKBOX); m_ToolBar.SetButtonStyle...
RadioBox和CheckBox实例代码
git clone到Redmine路径上的plugins/customfield_checkbox_utility 。 $ cd {RAILS_ROOT}/plugins $ git clone https://github.com/preciousplum/customfield_checkbox_utility 重新启动Redmine。 现在,您应该...
该资料包括dtree和dtree_checkbox(dtree复选框),众所周知,dtree是个不错的JS控件,好资料当然要和大家分享^_^
可以捆绑图片,文档等,高级版本,捆绑器,2020最新版本欢迎使用
简单实现自定义checkbox控件四种选择状态的图片样式
CheckBox DataGridView fonts example
代号One_Checkbox_Problem 代号One_Checkbox_Problem
一个有复选框的权限树.可以提取权限
使用CheckBox代替Frame/GroupBox的标题
<item name="android:button">@drawable/selector</item>//这个selector.xml中就是对应不同状态的CheckBox的背景图片 3:在selector.xml <selector xmlns:android=...
TCheckBox for Delphi
本demo实现功能为:Expandablelistview子项checkBox先获取已选择状态,在次过程中可修改子项选择,最终提交选择子类的项,并打印相关数据