1.RadioButtonCheckBox的差别:

a.单个RadioButton在选中后,通过点击无法变为未选中

单个CheckBox在选中后。通过点击能够变为未选中

b.一组RadioButton,仅仅能同一时候选中一个

一组CheckBox,能同一时候选中多个

c.RadioButton在大部分UI框架中默认都以圆形表示

CheckBox在大部分UI框架中默认都以矩形表示

2.RadioButton和RadioGroup的关系:

a.RadioButton表示单个圆形单选框,而RadioGroup是能够容纳多个RadioButton的容器

b.每一个RadioGroup中的RadioButton同一时候仅仅能有一个被选中

c.不同的RadioGroup中的RadioButton互不相干,即假设组A中有一个选中了,组B中依旧能够有一个被选中

d.大部分场合下。一个RadioGroup中至少有2个RadioButton

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

3.简介完后,先来看一下本应用中的效果图吧:

简单的一个弹出pop。然后里面提供了四种订单的状态,实现起来也不难,闲来看一下xml代码吧:

<?

xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/rl_order_parent"
android:orientation="vertical" > <RelativeLayout
android:id="@id/top_arrow"
android:layout_width="fill_parent"
android:layout_height="@dimen/height_title_bar" > <ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/btn_sort_arrow" />
</RelativeLayout> <RadioGroup
android:id="@+id/btn_sort"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/top_arrow"
android:background="@drawable/btn_sort_bg"
android:checkedButton="@id/btn_sort_unsigned"
android:gravity="center"
android:orientation="horizontal"
android:padding="10.0dip" > <RadioButton
android:id="@+id/btn_sort_all"
android:layout_width="0.0dip"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:background="#00000000"
android:button="@null"
android:clickable="true"
android:drawableTop="@drawable/btn_sort_all_selector"
android:gravity="center"
android:scaleType="matrix"
android:text="@string/btn_sort_all"
android:textColor="@color/grey_878787" /> <RadioButton
android:id="@+id/btn_sort_unsigned"
android:layout_width="0.0dip"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:background="#00000000"
android:button="@null"
android:clickable="true"
android:drawableTop="@drawable/btn_sort_unsigned_selector"
android:gravity="center"
android:scaleType="matrix"
android:text="@string/btn_sort_unsigned"
android:textColor="@color/blue_kuaidi100" /> <RadioButton
android:id="@+id/btn_sort_signed"
android:layout_width="0.0dip"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:background="#00000000"
android:button="@null"
android:clickable="true"
android:drawableTop="@drawable/btn_sort_signed_selector"
android:gravity="center"
android:scaleType="matrix"
android:text="@string/btn_sort_signed"
android:textColor="@color/grey_878787" /> <RadioButton
android:id="@+id/btn_sort_recycle"
android:layout_width="0.0dip"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:background="#00000000"
android:button="@null"
android:clickable="true"
android:drawableTop="@drawable/btn_sort_recycle_selector"
android:gravity="center"
android:scaleType="matrix"
android:text="@string/btn_sort_recycle"
android:textColor="@color/grey_878787" />
</RadioGroup> <View
android:id="@+id/btn_grey_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/btn_sort"
android:background="@color/black_7000" /> </RelativeLayout>

从xml布局文件里。看出使用了radiogroup,而且包括了四个radiobutton。这样便能够实现出那个弹出的popUpWindow.而且在RadioButton的图片中使用了状态选择器,分别在按下 选中和正常状态下。显示三种不同色值得图片。以一个为例。例如以下:

<?xml version="1.0" encoding="utf-8"?

>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/btn_sort_signed_pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/btn_sort_signed_selected" android:state_checked="true"/>
<item android:drawable="@drawable/btn_sort_signed_normal"/> </selector>

java代码例如以下。代码里都有凝视,目測能够看明确:

/**
* 显示签收状态的pop
*/
private void showOrderStatusPop() {
if (orderStatusPopView == null) {
orderStatusPopView = View.inflate(mContext, R.layout.pop_bill_sort,
null);
}
initOrderStatusPopView();
setCurrentCheckedItem();
setOrderStatusPopViewListener();
if (orderStatusPopupWindow == null) {
orderStatusPopupWindow = new PopupWindow(orderStatusPopView,
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
// 使其不聚集
orderStatusPopupWindow.setFocusable(false);
// 设置同意在外点击消失
orderStatusPopupWindow.setOutsideTouchable(true);
// 这个是为了点击“返回Back”也能使其消失,而且并不会影响你的背景
orderStatusPopupWindow.setBackgroundDrawable(new BitmapDrawable());
}
int i = DensityUtil.dip2px(mContext, 60.0f);
iv_arrow.setImageResource(R.drawable.arrow_up_float);
orderStatusPopupWindow.showAsDropDown(top, 0, -i);
} /**
* 初始化订单状态控件
*/
private void initOrderStatusPopView() {
rl_order_parent = (RelativeLayout) orderStatusPopView
.findViewById(R.id.rl_order_parent);
btn_sort = (RadioGroup) orderStatusPopView.findViewById(R.id.btn_sort);
btn_sort_all = (RadioButton) orderStatusPopView
.findViewById(R.id.btn_sort_all);
btn_sort_unsigned = (RadioButton) orderStatusPopView
.findViewById(R.id.btn_sort_unsigned);
btn_sort_signed = (RadioButton) orderStatusPopView
.findViewById(R.id.btn_sort_signed);
btn_sort_recycle = (RadioButton) orderStatusPopView
.findViewById(R.id.btn_sort_recycle); } /**
* 设置订单状态的监听
*/
private void setOrderStatusPopViewListener() {
rl_order_parent.setOnClickListener(this);
btn_sort_all.setOnClickListener(this);
btn_sort_unsigned.setOnClickListener(this);
btn_sort_signed.setOnClickListener(this);
btn_sort_recycle.setOnClickListener(this);
//给radioGroup设置选中变化的监听,便于检測当前选中了哪个,方便下次再次显示回显
btn_sort.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.btn_sort_all:
currentCheckedId = checkedId;
break;
case R.id.btn_sort_unsigned:
currentCheckedId = checkedId;
break;
case R.id.btn_sort_signed:
currentCheckedId = checkedId;
break;
case R.id.btn_sort_recycle:
currentCheckedId = checkedId;
break;
} }
});
btn_sort.check(currentCheckedId);
} /**
* 设置当前显示的状态
*/
private void setCurrentCheckedItem() {
switch (currentCheckedId) {
case R.id.btn_sort_all:
resetTextColor();
btn_sort_all.setTextColor(mContext.getResources().getColor(
R.color.blue_kuaidi100));
break;
case R.id.btn_sort_unsigned:
resetTextColor();
btn_sort_unsigned.setTextColor(mContext.getResources().getColor(
R.color.blue_kuaidi100));
break;
case R.id.btn_sort_signed:
resetTextColor();
btn_sort_signed.setTextColor(mContext.getResources().getColor(
R.color.blue_kuaidi100));
break;
case R.id.btn_sort_recycle:
resetTextColor();
btn_sort_recycle.setTextColor(mContext.getResources().getColor(
R.color.blue_kuaidi100));
break;
} } /**
* 重置文字颜色
*/
private void resetTextColor() {
btn_sort_all.setTextColor(mContext.getResources().getColor(
R.color.grey_878787));
btn_sort_unsigned.setTextColor(mContext.getResources().getColor(
R.color.grey_878787));
btn_sort_signed.setTextColor(mContext.getResources().getColor(
R.color.grey_878787));
btn_sort_recycle.setTextColor(mContext.getResources().getColor(
R.color.grey_878787)); }

此,我们实现了popPOP和radioGroup radioButton的组合。事实上,在实际应用。使用底部RadioGroup这些应用程序有很多,类似,知识这个小介绍这一点上。

高仿快车100--实战RadioGroup和RadioButton应用的更多相关文章

  1. Android ActionBar应用实战,高仿微信主界面的设计

    转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/26365683 经过前面两篇文章的学习,我想大家对ActionBar都已经有一个相对 ...

  2. 【第二版】高仿Android网易云音乐企业级项目实战课程介绍

    这是一门付费Android项目课程,我们只做付费课程:同时也感谢大家的支持. 这一节,对本课程做一个简单介绍,以及放一些项目效果图,如果想直接查看项目视频演示,可以直接在腾讯课堂查看[高仿Androi ...

  3. Android 高仿微信头像截取 打造不一样的自定义控件

    转载请表明出处:http://blog.csdn.net/lmj623565791/article/details/39761281,本文出自:[张鸿洋的博客] 1.概述 前面已经写了关于检测手势识别 ...

  4. Android -- 真正的 高仿微信 打开网页的进度条效果

    (本博客为原创,http://www.cnblogs.com/linguanh/) 目录: 一,为什么说是真正的高仿? 二,为什么要搞缓慢效果? 三,我的实现思路 四,代码,内含注释 五,使用方法与截 ...

  5. 微信小程序开发日记——高仿知乎日报(上)

    本人对知乎日报是情有独钟,看我的博客和github就知道了,写了几个不同技术类型的知乎日报APP 要做微信小程序首先要对html,css,js有一定的基础,还有对微信小程序的API也要非常熟悉 我将该 ...

  6. MySQL 系列(五) 多实例、高可用生产环境实战

    MySQL 系列(五) 多实例.高可用生产环境实战   第一篇:MySQL 系列(一) 生产标准线上环境安装配置案例及棘手问题解决 第二篇:MySQL 系列(二) 史上最屌.你不知道的数据库操作 第三 ...

  7. Android实现高仿QQ附近的人搜索展示

    本文主要实现了高仿QQ附近的人搜索展示,用到了自定义控件的方法 最终效果如下 1.下面展示列表我们可以使用ViewPager来实现(当然如果你不觉得麻烦,你也可以用HorizontalScrollVi ...

  8. iOS高仿app源码:纯代码打造高仿优质《内涵段子》

    iOS高仿app源码:纯代码打造高仿优质<内涵段子>收藏下来 字数1950 阅读4999 评论173 喜欢133 Github 地址 https://github.com/Charlesy ...

  9. 转-Fragment+ViewPager组件(高仿微信界面)

    http://www.cnblogs.com/lichenwei/p/3982302.html 什么是ViewPager? 关于ViewPager的介绍和使用,在之前我写过一篇相关的文章<安卓开 ...

随机推荐

  1. ural 1519 Formula 1

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1519 题目分类:插头dp 题意:求经过所有可行点的哈密顿回路的个数  * 不可走 . 可 ...

  2. MVVM Light须要注意的10个问题

    MVVM Light须要注意的10个问题 从使用XAML技术基础開始(实际上并非非常久曾经).我便关注MVVM(Model – View – ViewModel)模式.偶然接触到MVVM Light不 ...

  3. ASA QOS限速

    cisco的Qos限速和H3C的有点区别,不过总体来说,H3C的比较渣,单位是不一样的,H3C 的CAR单位的是kpbs,而cisco police限速时的单位是Bits per seconds,H3 ...

  4. adbetj657k

    http://www.zhihu.com/collection/24337307 http://www.zhihu.com/collection/24337259 http://www.zhihu.c ...

  5. 在Windows通过使用MinGW静态编译Assimp

    使用MinGW静态编译Assimp 到了5月份了.没有写一篇日志,于是自己从知识库里面拿出一篇文章充数吧.这次将要解说怎样在Windows下使用MinGW静态编译Assimp. Assimp是眼下比較 ...

  6. poj3259(spfa判负环)

    题目连接:http://poj.org/problem?id=3259 题意:John的农场里N块地,M条路连接两块地,W个虫洞,虫洞是一条单向路,会在你离开之前把你传送到目的地,就是当你过去的时候时 ...

  7. 在阿里云的CentOS环境中安装django

    购买了一台阿里云主机.操作系统为CentOS 6.5.准备在上面跑Django做Web开发.因为CentOS自带的python版本号较低,安装Django先要安装新版本号python.还是费了点周折. ...

  8. I2C操作笔记——以 AT24C04为例

    1.前言     对于大多数project师而言,I2C永远是一个头疼的问题.相比UART和SPI而言,I2C的时序要复杂一些,I2C组合变化也丰富一些.在这里以AT24C04为例说明I2C使用过程中 ...

  9. OpenStack安装与配置2

    第二部分 OpenStack安装与配置 一.引言   本章内容讲解如何在3台物理机上搭建最小化云平台,这3台机器分为称为Server1.Server2和Client1,之后的各章也是如此.Server ...

  10. 开启本地MySql数据库远程连接

    解决MySQL不允许从远程访问的方法 开启 MySQL 的远程登陆帐号有两大步: 1.确定服务器上的防火墙没有阻止 3306 端口. MySQL 默认的端口是 3306 ,需要确定防火墙没有阻止 33 ...