<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ebebeb" > <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <RelativeLayout
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#2b3134" > <ImageButton
android:id="@+id/infor_back"
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="@color/transparent"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:scaleType="centerInside"
android:src="@drawable/ac0" /> <View
android:id="@+id/view_temp"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:layout_toRightOf="@id/infor_back"
android:background="#14191A" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/view_temp"
android:text="违法停车告知单信息"
android:textColor="#ffffff"
android:textSize="18sp" />
</RelativeLayout> <RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="5dp"
android:background="#ffffff"
android:clickable="true" > <TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:gravity="center"
android:paddingLeft="5dp"
android:text="车牌号:"
android:textColor="#000000"
android:textSize="18sp" /> <TextView
android:id="@+id/plate_number"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_gravity="center_vertical"
android:layout_marginRight="20dp"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:text="5555555"
android:textColor="#000000"
android:textSize="18sp" /> <View
android:layout_width="match_parent"
android:layout_height="0.1dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:background="#dadada" />
</RelativeLayout> <RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#ffffff" > <TextView
android:id="@+id/car_cl"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:gravity="center"
android:paddingLeft="5dp"
android:text="车身颜色:"
android:textColor="#000000"
android:textSize="18sp" /> <EditText
android:id="@+id/car_color"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_gravity="center_vertical"
android:layout_marginRight="20dp"
android:layout_toRightOf="@id/car_cl"
android:cursorVisible="true"
android:gravity="center_vertical"
android:hint="请输入车身颜色"
android:paddingLeft="10dp"
android:singleLine="true"
android:textColor="#000000"
android:textSize="18sp" /> <View
android:layout_width="match_parent"
android:layout_height="0.1dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:background="#dadada" />
</RelativeLayout> <RelativeLayout
android:layout_width="wrap_content"
android:layout_height="192dp"
android:background="#ffffff"
android:clickable="true" > <TextView
android:id="@+id/car_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:gravity="center_horizontal"
android:paddingLeft="5dp"
android:paddingTop="15dp"
android:text="车辆类型:"
android:textColor="#000000"
android:textSize="18sp" /> <com.example.view.FlowRadioGroup
android:id="@+id/cartype_radio_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/car_type" > <RadioButton
android:id="@+id/big_carriage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="大型客车"
android:textColor="#000000"
android:textSize="14sp" /> <RadioButton
android:id="@+id/middle_carriage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="0dp"
android:text="中型客车"
android:textColor="#000000"
android:textSize="14sp" /> <RadioButton
android:id="@+id/small_carriage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="小型客车"
android:textColor="#000000"
android:textSize="14sp" /> <RadioButton
android:id="@+id/big_car"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="大型货车"
android:textColor="#000000"
android:textSize="14sp" /> <RadioButton
android:id="@+id/small_car"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="小型货车"
android:textColor="#000000"
android:textSize="14sp" /> <RadioButton
android:id="@+id/motor_cycle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="摩托车 "
android:textColor="#000000"
android:textSize="14sp" /> <RadioButton
android:id="@+id/cartype_else"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="其他"
android:textColor="#000000"
android:textSize="14sp" />
</com.example.view.FlowRadioGroup> <View
android:layout_width="match_parent"
android:layout_height="0.1dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:background="#dadada" />
</RelativeLayout> <RelativeLayout
android:layout_width="match_parent"
android:layout_height="94dp"
android:background="#ffffff"
android:clickable="true" > <TextView
android:id="@+id/plate_number_cl"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:gravity="center_horizontal"
android:paddingLeft="5dp"
android:paddingTop="15dp"
android:text="号牌颜色:"
android:textColor="#000000"
android:textSize="18sp" /> <com.example.view.FlowRadioGroup
android:id="@+id/plate_number_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/plate_number_cl" > <RadioButton
android:id="@+id/yellow_numb"
android:layout_width="33dp"
android:layout_height="24dp"
android:text="黄色"
android:textColor="#000000"
android:textSize="14sp" /> <RadioButton
android:id="@+id/blue_numb"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="蓝色"
android:textColor="#000000"
android:textSize="14sp" /> <RadioButton
android:id="@+id/black_numb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="黑色"
android:textColor="#000000"
android:textSize="14sp" /> <RadioButton
android:id="@+id/color_else"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="其他"
android:textColor="#000000"
android:textSize="14sp" />
</com.example.view.FlowRadioGroup> <View
android:layout_width="match_parent"
android:layout_height="0.1dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:background="#dadada" />
</RelativeLayout>
</LinearLayout> <RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:background="#2b3134" > <LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal" > <Button
android:id="@+id/information_change"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_weight="1"
android:background="@android:color/transparent"
android:gravity="center"
android:text="修改"
android:textColor="@android:color/white"
android:textSize="20dp" /> <View
android:id="@+id/infor_view_temp"
android:layout_width="4dp"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="@id/information_change"
android:background="#14191A" /> <Button
android:id="@+id/information_sure"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_weight="1"
android:background="@android:color/transparent"
android:gravity="center"
android:text="确定"
android:textColor="@android:color/white"
android:textSize="20dp" />
</LinearLayout>
</RelativeLayout> </RelativeLayout>
package com.example.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RadioGroup; public class FlowRadioGroup extends RadioGroup { public FlowRadioGroup(Context context, AttributeSet attrs) {
super(context, attrs); } @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int maxWidth = MeasureSpec.getSize(widthMeasureSpec);
int childCount = getChildCount();
int x = 0;
int y = 0;
int row = 0; for (int index = 0; index < childCount; index++) {
final View child = getChildAt(index);
if (child.getVisibility() != View.GONE) {
child.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
// 此处增加onlayout中的换行判断,用于计算所需的高度
int width = child.getMeasuredWidth();
int height = child.getMeasuredHeight();
x += width;
y = row * height + height;
if (x > maxWidth) {
x = width;
row++;
y = row * height + height;
}
}
}
// 设置容器所需的宽度和高度
setMeasuredDimension(maxWidth, y); } @Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int childCount = getChildCount();
int maxWidth = r - l;
int x = 0;
int y = 0;
int row = 0;
for (int i = 0; i < childCount; i++) {
final View child = this.getChildAt(i);
if (child.getVisibility() != View.GONE) {
int width = child.getMeasuredWidth();
int height = child.getMeasuredHeight();
x += width;
y = row * height + height;
if (x > maxWidth) {
x = width;
row++;
y = row * height + height;
}
child.layout(x - width, y - height, x, y);
}
}
} }
// 注册单选按钮的监听事件
cartype_radio_group.setOnCheckedChangeListener(listener1);
plate_number_group.setOnCheckedChangeListener(listener2);
car_color = (EditText) findViewById(R.id.car_color);
back = (ImageButton) findViewById(R.id.infor_back); } private RadioGroup.OnCheckedChangeListener listener1 = new RadioGroup.OnCheckedChangeListener() { @Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == big_carriage.getId()) {
cartype = big_carriage.getText().toString();
} else if (checkedId == middle_carriage.getId()) {
cartype = middle_carriage.getText().toString();
} else if (checkedId == small_carriage.getId()) {
cartype = small_carriage.getText().toString();
} else if (checkedId == big_car.getId()) {
cartype = big_car.getText().toString();
} else if (checkedId == small_car.getId()) {
cartype = small_car.getText().toString();
} else if (checkedId == motor_cycle.getId()) {
cartype = motor_cycle.getText().toString();
} else {
cartype = color_else.getText().toString();
} }
};
private RadioGroup.OnCheckedChangeListener listener2 = new RadioGroup.OnCheckedChangeListener() { @Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == yellow_numb.getId()) {
color_car = yellow_numb.getText().toString();
} else if (checkedId == blue_numb.getId()) {
color_car = blue_numb.getText().toString();
} else if (checkedId == black_numb.getId()) {
color_car = black_numb.getText().toString();
} else {
color_car = yellow_numb.getText().toString();
} }
};

android开发之单选按钮的更多相关文章

  1. Android开发 ---基本UI组件3:单选按钮、多选按钮、下拉列表、提交按钮、重置按钮、取消按钮

    Android开发 ---基本UI组件2 1.activity_main.xml 描述: 定义一个用户注册按钮 <?xml version="1.0" encoding=&q ...

  2. Android开发 ---基本UI组件2:图像按钮、单选按钮监听、多选按钮监听、开关

    Android开发 ---基本UI组件2 1.activity_main.xml 描述: 定义一个按钮 <?xml version="1.0" encoding=" ...

  3. Android开发ListView嵌套ImageView实现单选按钮

    做Android开发两年的时间,技术稍稍有一些提升,刚好把自己实现的功能写出来,记录一下,如果能帮助到同行的其他人,我也算是做了件好事,哈哈!!废话不多说,先上个图. 先上一段代码: if (last ...

  4. Android开发-之认识palette

    Android开发中,Google工程师已经给我们封装好了很多的按钮,使得我们在开发中非常的方便和便捷. 那么今天就来认识一下常用的按钮,那么在之前的课程中我已经详细讲过了Button按钮,那么这里就 ...

  5. Android开发1:基本UI界面设计——布局和组件

    前言 啦啦啦~本学期要开始学习Android开发啦~ 博主在开始学习前是完完全全的小白,只有在平时完成老师要求的实验的过程中一步一步学习~从此篇博文起,博主将开始发布Android开发有关的博文,希望 ...

  6. 【Android学习】《Android开发视频教程》第一季笔记

    视频地址: http://study.163.com/course/courseMain.htm?courseId=207001 课时5    Activity基础概念 1.Android开发技术结构 ...

  7. Android开发学习清单

    目录: 第1章 Android应用与开发环境1.1 Android的发展和历史1.1.1 Android的发展和简介1.1.2 Android平台架构及特性1.2 搭建Android开发环境1.2.1 ...

  8. Android开发中的问题及相应解决(持续更新)

    最近博客写的少了,以后还得经常更新才行. ------------------------------------------------------------ 1.特定业务需求下try cath ...

  9. 转发:Android开发?用C#!!

    转发自 最近偶然在QQ技术群里见到有人提起用C#开发Android,当时我感觉到很诧异:Android不是只能用Java开发吗?何时可以使用C#了?那个群友便告知我:mono. 百度一下吧!搜到了mo ...

随机推荐

  1. 简单工厂模式(Simple Factory)

    从设计模式的类型上来说,简单工厂模式是属于创建型模式,又叫做静态工厂方法(Static Factory Method)模式,但不属于23种GOF设计模式之一.简单工厂模式是由一个工厂对象决定创建出哪一 ...

  2. 复制过来的东西也不靠谱,微信公众号第三方平台的API

    API:https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&veri ...

  3. 在VS下使用 GitFlow管理项目开发

    在VS下使用 GitFlow管理项目开发 1.右键将你的解决方案添加到源代码管理,如果你的VS没有安装git,会提示安装,安装完成之后,在团队资源管理可以看到如下界面 (图一) 2.安装gitflow ...

  4. Asp.net中Json的序列化和反序列化(一)

    JSON是专门为浏览器中的网页上运行的JavaScript代码而设计的一种数据格式.在网站应用中使用JSON的场景越来越多,本文介绍ASP.NET中JSON的序列化和反序列化,主要对JSON的简单介绍 ...

  5. HDU 5876 (大连网赛1009)(BFS + set)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5876 题意:给定一个图(n个顶点m条边),求其补图最短路 思路:集合a表示当前还未寻找到的点,集合b表 ...

  6. mysql -workbench : Error cause by ' sql-mode = only-full-group-by'

    当mysql出现"only-full-group-by"问题时,是mysql的sql_mode设置出现了问题. 解决: 1.  找到mysql的 my.cnf文件,我的文件路径是: ...

  7. strncpy基本用法

    见百度百科. 注意这句话: (c/c++)复制src中的内容(字符,数字.汉字....)到dest,复制多少由num的值决定,返回指向dest的指针.如果遇到null字符('\0'),且还没有到num ...

  8. python 杨辉三角

    前提:端点的数为1. 每个数等于它上方两数之和. 每行数字左右对称,由1开始逐渐变大. 第n行的数字有n项. 第n行数字和为2n-1. 第n行的m个数可表示为 C(n-1,m-1),即为从n-1个不同 ...

  9. 关于HTML标签(元素)的那些事?

    关于HTML标签(元素)的那些事? 在战场上,知己知彼,方能百战百胜:在商场上,知己知彼,亦能呼风唤雨:在情场上,知己知彼,才能幸福美满.当然啦,在我们前端开发上,亦要知己知彼,才能叱咤风云.关于HT ...

  10. Python 安装mysqldb

    切换目录: cd /usr/local/src/ 一.下载资源 wget http://sourceforge.net/projects/mysql-python/files/mysql-python ...