GVKun编程网logo

在Android中使用setError的RadioGroup空字段检查(android string 空格)

10

本文将为您提供关于在Android中使用setError的RadioGroup空字段检查的详细介绍,我们还将为您解释androidstring空格的相关知识,同时,我们还将为您提供关于androidR

本文将为您提供关于在Android中使用setError的RadioGroup空字段检查的详细介绍,我们还将为您解释android string 空格的相关知识,同时,我们还将为您提供关于android RadioGroup、android radiogroup 不可编辑、Android RadioGroup 和 RadioBu…、Android radioGroup 怎样限制只能选一次的实用信息。

本文目录一览:

在Android中使用setError的RadioGroup空字段检查(android string 空格)

在Android中使用setError的RadioGroup空字段检查(android string 空格)

我想知道如何使用RadioButton的[gender_b,gender_c]为RadioGroup [性别]设置错误(如果它为null).

这是我获得RadioButton值的方式:

private boolean genradiocheck() {


    boolean gender_flag = false;
    if (gender.getCheckedRadioButtonId() == -1) {



    } else {
        gender_b = (RadioButton) findViewById(gender
                .getCheckedRadioButtonId());
        System.out.println("*********************" + gender_b.getText());
        gender_flag = true;
    }

    return gender_flag;
}

现在我的问题是,如何将其放入字符串并检查空值?

这是用于注册表单验证.谢谢.

解决方法

setError()方法不适用于RadioGroup,但您可以将其应用于RadioButton.

跟着这些步骤:

>制作RadioButton对象并使用RadioGroup的最后一项初始化它.

RadioButton lasTradioBtn = (RadioButton) view.findViewById(R.id.lasTradioBtn);

>下面的代码检查是否已检查RadioGroup,如果没有则设置错误.

if(group.getCheckedRadioButtonId()<=0){//Grp is your radio group object
    lasTradioBtn.setError("Select Item");//Set error to last Radio button          
}

编辑:

如果你想清除错误:

lasTradioBtn.setError(null);

希望这会有所帮助.

android RadioGroup

android RadioGroup

RadioGroup 的父控件是:LinearLayout

RadioGroup 是一个单选按钮组,RadioGroup 可将各自不同的 RadioButton , 在 RadioGroup 中的各个 radiobutton 是互斥的,也就是说,这些 radiogroup 中单选按钮只能选中一个,当一个被选中的时候其他就设置未被选中

三、内部类

    Class RadioGroup.LayoutParams

     WRAP_CONTENT(包裹内容)的子组件在 XML 文件中没有指定相应的宽度和高度的话,可以使用的布局参数默认设置的默认设置

    Interface RadioGroup.OnCheckedChangeListener

    当单选按钮组中的单选按钮的勾选状态发生改变时,所要调用的回调函数的接口类

四、公共方法

public void addView (View child, int index, ViewGroup.LayoutParams params)

使用指定的布局参数添加一个子视图

参数

child 所要添加的子视图

index 将要添加子视图的位置

params 所要添加的子视图的布局参数

public void check (int id)

如果传递 -1 作为指定的选择标识符来清除单选按钮组的勾选状态,相当于调用 clearCheck() 操作

参数

  id 该组中所要勾选的单选按钮的唯一标识符(id

参见

  getCheckedRadioButtonId()

  clearCheck()

public void clearCheck ()

清除当前的选择状态,当选择状态被清除,则单选按钮组里面的所有单选按钮将取消勾选状态,getCheckedRadioButtonId() 将返回 null

参见

  check(int)

  getCheckedRadioButtonId()

public RadioGroup.LayoutParams generateLayoutParams (AttributeSet attrs)

基于提供的属性集合返回一个新的布局参数集合

参数

  attrs 用于生成布局参数的属性

返回值

  返回一个 ViewGroup.LayoutParams 或其子类的实例

public int getCheckedRadioButtonId ()

返回该单选按钮组中所选择的单选按钮的标识 ID,如果没有勾选则返回 -1

返回值

  返回该单选按钮组中所选择的单选按钮的标识 ID

参见

  check(int)

clearCheck()

public void setOnCheckedChangeListener (RadioGroup.OnCheckedChangeListener listener)

注册一个当该单选按钮组中的单选按钮勾选状态发生改变时所要调用的回调函数

参数

  listener 当单选按钮勾选状态发生改变时所要调用的回调函数

public void setOnHierarchyChangeListener (ViewGroup.OnHierarchyChangeListener listener)

注册一个当子内容添加到该视图或者从该视图中移除时所要调用的回调函数

参数

listener 当层次结构发生改变时所要调用的回调函数

  五、受保护方法

protected LinearLayout.LayoutParams generateDefaultLayoutParams ()

当布局为垂直方向时,将返回一个宽度为 “填充父元素”(MATCH_PARENT),高度为 “包裹内容” 的布局参数集合,如果为水平方向时,将返回宽度为 “包裹内容”,高度为 “填充父元素” 的布局参数集合

(match_parent 即为 fill_parent,public static final int FILL_PARENT/MATCH_PARENT = -1 )

  返回值

返回一个默认的布局参数集合

protected void onFinishInflate ()

当视图从 XML 中加载,且相应的子视图被添加之后,调用该方法,

即使子类重写了该方法,应该确保去调用父类的方法(通常放在方法在第一句),这样才能完成相应的调用参数

  返回值

返回一个默认的布局参数集合

 

 

android radiogroup 不可编辑

android radiogroup 不可编辑

我在界面中有一个 radiogroup 里面有很多个 radiobutton,每切换一下 radiobutton 都会请求一次网络,我想做成每次网络请求完了之后 radiobutton 才可以切换,在网络请求的过程中不能切换 radiobutton 怎么办呢?


Android RadioGroup 和 RadioBu…

Android RadioGroup 和 RadioBu…

http://my.oschina.net/amigos/blog/59261


实现 RadioButton 由两部分组成 , 也就是 RadioButton RadioGroup 配合使用.RadioGroup 是单选组合框,可以容纳多个 RadioButton 的容器. 在没有 RadioGroup 的情况下,RadioButton 可以全部都选中;当多个 RadioButton RadioGroup 包含的情况下,RadioButton 只可以选择一个。并用 setOnCheckedChangeListener 来对单选按钮进行监听

 

01 RadioGroup相关属性:
02  
03 RadioGroup.getCheckedRadioButtonId ();--获取选中按钮的id
04  
05 RadioGroup.clearCheck ();//---清除选中状态
06  
07 RadioGroup.check (int id);//---通过参入选项id来设置该选项为选中状态如果传递-1作为指定的选择标识符来清除单选按钮组的勾选状态,相当于调用clearCheck()操作
08  
09 setOnCheckedChangeListener (RadioGroup.OnCheckedChangeListener listener); //--一个当该单选按钮组中的单选按钮勾选状态发生改变时所要调用的回调函数
10  
11 addView (View child, int index, ViewGroup.LayoutParams params);//---使用指定的布局参数添加一个子视图
12  
13 //参数 child 所要添加的子视图    index 将要添加子视图的位置  params 所要添加的子视图的布局参数
14  
15 RadioButton.getText();//获取单选框的值
16  
17 //此外,RadioButton的checked属性设置为true,代码里调用RadioButton的check(id)方法,不会触发onCheckedChanged事件

 

RadioButton 和 RadioGroup 的关系:

1、RadioButton 表示单个圆形单选框,而 RadioGroup 是可以容纳多个 RadioButton 的容器

2、每个 RadioGroup 中的 RadioButton 同时只能有一个被选中

3、不同的 RadioGroup 中的 RadioButton 互不相干,即如果组 A 中有一个选中了,组 B 中依然可以有一个被选中

4、大部分场合下,一个 RadioGroup 中至少有 2 个 RadioButton

5、大部分场合下,一个 RadioGroup 中的 RadioButton 默认会有一个被选中,并建议您将它放在 RadioGroup 中的起始位置

 

看案例:

1. 定义布局文件:

 

01
0
0
 
 
  • 上一篇Android单选框基本应用方式讲解ZZ
  • 下一篇安卓加密壳(dexcrypt)&nbsp;,&amp;nbs…

  相关文章推荐
  • Android (FragmentTabHost+RadioGroup)实现底部bar
  • 【Android每日一讲】2012.11.27 向左或向右 - RadioGroup组与onCheckedChanged事件
  • android&nbsp;RadioGroup和RadioB…
  • Android开发控件之CheckBox、RadioGroup、RadioButton
  • [android]控件CheckBox/RadioGroup/RadioButton的常用属性---单复选控件
  • Android学习笔记(四)CheckBox、RadioGroup、ProgressBar、ListView、Spinner
  • Android初级教程 - RadioGroup、RadioButton、CheckBox(单复选框)的简单使用
  • Android UI设计 RadioGroup单选按钮用法
  • Android7.0中文API -- RadioGroup
  • Android:解决RadioGroup中RadioButton的图片自定义及每项间隔距离一样
猜你在找
深度学习基础与TensorFlow实践
【在线峰会】前端开发重点难点技术剖析与创新实践
【在线峰会】一天掌握物联网全栈开发之道
【在线峰会】如何高质高效的进行Android技术开发
机器学习40天精英计划
Python数据挖掘与分析速成班
微信小程序开发实战
JFinal极速开发企业实战
备战2017软考 系统集成项目管理工程师 学习套餐
Python大型网络爬虫项目开发实战(全套)
查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
快速回复 TOP
    个人资料

    leansmall
    • 访问:279905次
    • 积分:5401
    • 等级:
      积分:5401
    • 排名:第4627名
    • 原创:211篇
    • 转载:273篇
    • 译文:0篇
    • 评论:6条
    文章搜索
    文章分类
  • Android安装及配置(107)
  • Android资源(52)
  • Android Activity(20)
  • Android界面和组件(63)
  • Android数据存储(24)
  • Android多媒体(2)
  • Android图形动画(13)
  • Android网络(13)
  • Android其他(24)
  • Android JAVA(21)
  • Eclipse &Android Studio(3)
  • cocos2d安装设置(16)
  • cocos2d代码编写(41)
  • cocos2d其他(3)
  • IOS开发(16)
  • cocos2d安卓平台(5)
  • cocos2d-IOS平台(11)
  • C++与C#(3)
  • Unity3D安装设置(12)
  • Unity3D脚本(4)
  • Unity3D平台转换(7)
  • Unity3D其他(7)
  • Server开发(10)
    文章存档
  • 2017年06月(12)
  • 2017年05月(16)
  • 2017年04月(1)
  • 2017年03月(4)
  • 2017年02月(10)
  • 2017年01月(2)
  • 2016年12月(15)
  • 2016年07月(1)
  • 2016年06月(13)
  • 2016年04月(2)
  • 2016年03月(3)
  • 2016年02月(8)
  • 2016年01月(9)
  • 2015年12月(11)
  • 2015年10月(6)
  • 2015年09月(1)
  • 2015年08月(48)
  • 2015年07月(24)
  • 2015年06月(4)
  • 2015年05月(7)
  • 2015年04月(2)
  • 2015年03月(5)
  • 2015年01月(7)
  • 2014年12月(16)
  • 2014年11月(6)
  • 2014年09月(2)
  • 2014年08月(2)
  • 2014年07月(20)
  • 2014年06月(43)
  • 2014年05月(185)
    阅读排行
  • app 用 Application Loader上传成功了 但是iTunes connect里依然未显示构建版本(4712)
  • Unity 发布到IOS的注意事项(4213)
  • Could not find class ''com.tendcloud.tenddata.l'', 解决办法(2889)
  • android 判断字符串是否为数字或中文或字母(2853)
  • Dx warning: Ignoring InnerClasses attribute for an anonymous inner class(2810)
  • INSTALL_FAILED_NO_MATCHING_ABIS 的解决办法(2655)
  • android 程序中res/values-v14/styles.xml报错的解决办法(2571)
  • error C2039: “create”: 不是“cocos2d::GLView”的成员,出错解决办法(2203)
  • Unity 发布到Android的注意事项开发环境(2198)
  • 分享20个Android游戏源码,…(2180)
    评论排行
  • cocos2d-x 3.6运行cocos run出现Ndk build failed解决办法(4)
  • app 用 Application Loader上传成功了 但是iTunes connect里依然未显示构建版本(2)
  • Android开发:碎片Fragment完全解析…(0)
  • android学习1(0)
  • 在pc上&nbsp;运行android&nbsp;4.2(0)
  • Android的模拟器,在ADT中调试运行…(0)
  • emulator:&nbsp;Failed&nbsp;to&amp;nb…(0)
  • Failed&nbsp;to&nbsp;open&amp;n…(0)
  • unity代码在Xcode上提示:A build only device cannot be used to run this target(0)
  • Android快速搭建模拟器环境另类方…(0)
    推荐文章
    • * CSDN日报20170620——《找一个好工作,谈一份好薪水》
    • * 一文理清散乱的物联网里开发者必须关注的技术!
    • * Android APK反编译就这么简单 详解
    • * 如何选择优化器 optimizer
    • * 性能测试场景设计杂谈
    • * 每周荐书:架构、Scratch、增长黑客(评论送书)
    最新评论
  • app 用 Application Loader上传成功了 但是iTunes connect里依然未显示构建版本

    u010401347: 有可能是ipa调用apple私有api了

  • app 用 Application Loader上传成功了 但是iTunes connect里依然未显示构建版本

    u010401347: 有可能是ipa调用apple私有api了

收藏助手

Android radioGroup 怎样限制只能选一次

Android radioGroup 怎样限制只能选一次

Android radioGroup 怎样限制只能选一次,就是选择之后就不能再改变了

今天关于在Android中使用setError的RadioGroup空字段检查android string 空格的介绍到此结束,谢谢您的阅读,有关android RadioGroup、android radiogroup 不可编辑、Android RadioGroup 和 RadioBu…、Android radioGroup 怎样限制只能选一次等更多相关知识的信息可以在本站进行查询。

本文标签: