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. Delphi的VMT的结构图,很清楚

    Every Delphi class is defined internally by its vmt—​its virtual-method table. The vmt contains a li ...

  2. Api之Cors跨域以及其他跨域方式

    Web Api之Cors跨域以及其他跨域方式(三)   我们知道ajax不能跨域访问,但是有时我们确实需要跨域访问获取数据,所以JSONP就此诞生了,其本质使用的是Script标签,除JSONP以外还 ...

  3. 用代码定位硬盘上的文件(使用ShellExecute执行explorer /select命令,其它参数也很全)

    问题:如何用代码控制资源浏览器,并定位到指定的文件? 答:使用ShellExecute,配合explorer即可 ShellExecute(Application.Handle, 'open', PC ...

  4. Access Violation at address 00000000.Read of address 00000000 解决办法

    是数组越标或没有初始化某个对象之类的问题,搂住细细检查一下代码, 使用指针前未做检查,而这个指针未初始化. 可能是new后没有delete,这样出现溢出的可能性比较大     检查代码或者跟踪试试 使 ...

  5. curl订单具体解释

    为windows假设用户Cygwin模拟unix环境的话,不会有带curl命令,拥有设备,它建议使用Gow为了模拟,它已经自带curl工具,直接安装之后cmd使用环境curl命令可以,由于路径是自己主 ...

  6. OCA读书笔记(17) - 移动数据

    Sql*load 1. sql*loader的文件有哪些? 日志文件:概述了作业的成功与失败以及所有相关错误的细节 错误文件(bad file):从输入文件中抽取的行可能会被sqlldr丢弃(原因可能 ...

  7. iOS文件保存策略

    Where You Should Put Your App’s Files To prevent the syncing and backup processes on iOS devices fro ...

  8. CCEditBox/CCEditBoxImplIOS

    #ifndef __CCEditBoxIMPLIOS_H__ #define __CCEditBoxIMPLIOS_H__ #include "cocos2d.h" #if (CC ...

  9. C语言sizeofkeyword

    说明: ******C语言sizeof是keyword.是一个操作符.它不是一个函数.用于计算可变.或内存数据字节数占用类型. ******sizeof有三种不同的方式: ***sizeof(变量名) ...

  10. Apache James使用的方法及相关心得(转)

    经过一番的辛苦努力,终于把James 配置搞定啦,好记性不如烂笔头啊,赶紧记下我的成功经过,以备以后查阅! 首先要做的就是配置域名的MX 记录啦: 先添加一条A记录: mail.abc.com 指向 ...