android checkbox是否选中,Android 中如何处理checkbox的选中、未选中

android checkbox是否选中,Android 中如何处理checkbox的选中、未选中xml页面布局android:orientation=”vertical”android:layout_width=”fill_parent”android:layout_height=”fill_parent”>android:text=”Plain”android:layout_width=”wrap_content”android:layout_height=”wrap_content…

大家好,又见面了,我是你们的朋友全栈君。

xml页面布局

android:orientation=”vertical”

android:layout_width=”fill_parent”

android:layout_height=”fill_parent”

>

android:text=”Plain”

android:layout_width=”wrap_content”

android:layout_height=”wrap_content”

/>

android:text=”Bold”

android:layout_width=”wrap_content”

android:layout_height=”wrap_content”

android:textStyle=”bold”

/>

android:text=”Serif”

android:layout_width=”wrap_content”

android:layout_height=”wrap_content”

android:typeface=”serif”

/>

android:text=”Italic”

android:layout_width=”wrap_content”

android:layout_height=”wrap_content”

android:textStyle=”italic”

/>

android:layout_width=”wrap_content”

android:layout_height=”wrap_content”

android:text=”获取CheckBox的值”

/>

—————————————————————————————-

10b0eb778b5424efde0e6143d6870955.gif

java类:

package com.zgct.activity;

import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.CheckBox;

public class CheckBoxActivity extends Activity {

CheckBox plain_cb;

CheckBox serif_cb;

CheckBox italic_cb;

CheckBox bold_cb;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setTitle(“CheckBoxActivity”);

setContentView(R.layout.check_box);

find_and_modify_text_view();

}

private void find_and_modify_text_view(){

plain_cb = (CheckBox) findViewById(R.id.plain_cb);

serif_cb = (CheckBox) findViewById(R.id.serif_cb);

italic_cb = (CheckBox) findViewById(R.id.italic_cb);

bold_cb = (CheckBox) findViewById(R.id.bold_cb);

Button get_view_button = (Button)findViewById(R.id.get_view_button);

get_view_button.setOnClickListener(get_view_button_listener);

}

private Button.OnClickListener get_view_button_listener = new Button.OnClickListener(){

public void onClick(View v){

String r = “”;

if(plain_cb.isChecked()){

r = r + “,” + plain_cb.getText();

}

if(serif_cb.isChecked()){

r = r + “,” + serif_cb.getText();

}

if(bold_cb.isChecked()){

r = r + “,” + bold_cb.getText();

}

if(italic_cb.isChecked()){

r = r + “,” + italic_cb.getText();

}

setTitle(“Checked: ” + r);

}

};

}0b1331709591d260c1c78e86d0c51c18.png

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/150577.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Python Selenium库的使用「建议收藏」

    (一)Selenium基础入门教程:Selenium官网教程1.Selenium简介Selenium是一个用于测试网站的自动化测试工具,支持各种浏览器包括Chrome、Firefox、Safari等主流界面浏览器,同时也支持phantomJS无界面浏览器。2.支持多种操作系统如Windows、Linux、IOS、Android等。3.安装Selenium…

    2022年4月14日
    35
  • Ubuntu安装VScode(搬运命令行)「建议收藏」

    Ubuntu安装VScode(搬运命令行)「建议收藏」ToinstallVisualStudioCodeonyourUbuntusystem,followthesesteps.First,updatethepackagesindexandinstallthedependenciesbytyping:sudoaptupdatesudoaptinstallsoftware-properties-commonapt-transport-httpswgetNext,importtheMic.

    2022年9月18日
    4
  • 【综合实训】图书管理系统——详细设计说明书

    【综合实训】图书管理系统——详细设计说明书文章目录1引言1.1编写目的1.2项目背景1.3定义1.4参考资料2总体设计2.1需求概述2.2软件结构3模块描述3.1模块基本信息3.2功能概述3.3算法3.4模块处理逻辑3.5接口3.6性能3.7测试计划1引言1.1编写目的  本报告的目的是对高校图书管理系统进行详细设计说明,以便用户及项目开发人员了解产品详细的设计与实现,为开发人员提供开发参考书。以下叙述将结合文字描述、伪代码,图表等来描述高校图书管理系统的详细设计和相关的模块描述。本报告的预期读者有客户、项

    2022年5月29日
    36
  • 设计模式(4)-对象创建型模式-Prototype模式

    设计模式(4)-对象创建型模式-Prototype模式

    2022年1月22日
    49
  • Fiddler实现手机抓包——入门

    Fiddler实现手机抓包——入门随时随地阅读更多技术实战干货,获取项目源码、学习资料,请关注源代码社区公众号(ydmsq666)、博主微信(guyun297890152)、QQ技术交流群(183198395)。from:https://blog.csdn.net/gld824125233/article/details/52588275手机用fiddler抓包电脑最好是笔记本,这样能和手机保持统一局域网内;其他不…

    2022年6月15日
    52
  • 计算机病毒模块测试题,计算机病毒分类测试题集

    计算机病毒模块测试题,计算机病毒分类测试题集以下有关计算机病毒分类的陈述______是正确的.A)病毒分为十二类B)病毒分为操作系统类型和文件类型C)没有分类D)病毒分为外壳型和侵入型根据计算机病毒的破坏能力,计算机病毒可分为A.良性病毒B.恶性病毒C.网络病毒D.引导病毒根据计算机病毒的存在方式进行分类,通常可以分为().A.复杂病毒B.引导病毒C.文件病毒D.网络病毒这个问题是一个选择题.请帮助给出正确的答案和分析,谢…

    2022年5月9日
    34

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号