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. FindWindowEx使用方法

    函数功能:该函数获得一个窗体的句柄,该窗体的类名和窗体名与给定的字符串相匹配.这个函数查找子窗体,从排在给定的子窗体后面的下一个子窗体開始.在查找时不区分大写和小写. 函数原型:HWND FindWi ...

  2. jQuery选择

    1.基本的选择 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY29tZW9uc3RvbmU=/font/5a6L5L2T/fontsize/400/fil ...

  3. Ubuntu下Chromium源码的编译

    一.失败的经历 印象中,谷歌建议Ubuntu建议版本为10.4.但是我找不到出处了,模糊的印象.不知道是不是这样? 1.Ubuntu10.4.3-desktop-amd64 + Virtual Box ...

  4. OCP读书笔记(2) - 配置恢复

    RMAN的命令类型 1. sqlplus命令 [oracle@oracle admin]$ export ORACLE_SID=orcl [oracle@oracle admin]$ rman tar ...

  5. POJ2599+POJ2082【最大矩形面积】

    题目链接:http://poj.org/problem?id=2559 题目链接:http://poj.org/problem?id=2082 这一类题目的解法,不知自己闲着没事就做了两个. 果然压栈 ...

  6. poj 3278 Catch That Cow (bfs搜索)

    Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 46715   Accepted: 14673 ...

  7. “>>”和“>>>” java

    “>>”算术右移运算符, 表示带符号右移,它使用最高位填充移位后左侧的空位.右移的结果为:每移一位,第一个操作数被2除一次,移动的次数由第二个操作数确定.按二进制形式把所有的数字向右移动对 ...

  8. Android支付接入(八):Amazon亚马逊支付

    下面跟大家一起走一遍Amazon亚马逊的支付,亚马逊目前刚把业务拓展到大陆市场,但这并不代表Amazon支付不成熟,恰恰相反,Amazon的支付流程,支付结果获取及测试另人称赞,支付流程.测试流程简洁 ...

  9. 在ireport中使用checkbox

    在网上搜索了很多实现checkbox的办法, 主要是利用打钩图片实现. 下面是我的做法,也不怎么高明, 不过比利用图片好. 后台 map.put("lifeTimePartFlag" ...

  10. 深入java并发Lock一

    java有像syncronized这种内置锁,但为什么还须要lock这种外置锁? 性能并非选择syncronized或者lock的原因,jdk6中syncronized的性能已经与lock相差不大. ...