以JSONobject形式提交http请求
总结一下设置图标的三种方式:
(1)button属性:主要用于图标大小要求不高,间隔要求也不高的场合。
(2)background属性:主要用于能够以较大空间显示图标的场合。
(3)drawableLeft属性:主要用于对图标与文字之间的间隔有要求的场合。
注意使用 background 或者 drawableLeft时 要设置 android:button="@null"
监听:
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
}
});
1
2
3
4
5
6
7
下面是一个例子:
效果图:
布局文件: activity_radio_button.xml 中使用
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:button="@null"
android:checked="true"
android:drawablePadding="10dp"
android:drawableTop="@drawable/selback"
android:gravity="center_horizontal"
android:text="男"
android:textColor="#FF0033"
/>
<RadioButton
android:id="@+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:button="@null"
android:drawablePadding="10dp"
android:drawableTop="@drawable/selback"
android:gravity="center_horizontal"
android:text="女"
android:textColor="#000000"
/>
</RadioGroup>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
选择器:selback.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@mipmap/on"/>
<item android:drawable="@mipmap/off"/>
</selector>
1
2
3
4
选择器用到的图片:
RadioButtonActivity 中监听选中
package rolechina.jremm.com.test4;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.Toast;
public class RadioButtonActivity extends Activity {
private RadioGroup radioGroup;
private RadioButton radioButton1;
private RadioButton radioButton2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_radio_button);
radioGroup = findViewById(R.id.radioGroup);
radioButton1 = findViewById(R.id.radioButton1);
radioButton2 = findViewById(R.id.radioButton2);
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// 选中 文字 显示红色,没有选中显示黑色
if(radioButton1.isChecked()) {
radioButton1.setTextColor(Color.parseColor("#FF0033"));
}else{
radioButton1.setTextColor(Color.parseColor("#000000"));
}
if(radioButton2.isChecked()) {
radioButton2.setTextColor(Color.parseColor("#FF0033"));
}else{
radioButton2.setTextColor(Color.parseColor("#000000"));
}
}
});
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
---------------------
以JSONobject形式提交http请求的更多相关文章
- vue axios使用form-data的形式提交数据的问题
vue axios使用form-data的形式提交数据vue axios request payload form data由于axios默认发送数据时,数据格式是Request Payload,而并 ...
- php ajax提交post请求出现数组被截断情况的解决方法
一.场景 今天做保存专题商品列表的时候发现,前端明明有2300多条数据,但是实际服务端接受存入数据库才166条 二.解决过程 经过调试发现前端页面提交post请求时数据量是正确的,但到服务端只能接受到 ...
- Android 使用HttpClient方式提交POST请求
final String username = usernameEditText.getText().toString().trim(); final String password = passwr ...
- Android 使用HttpClient方式提交GET请求
public void httpClientGet(View view) { final String username = usernameEditText.getText().toString() ...
- 使用libcurl提交POST请求
最近在学习libcurl,并利用它提交POST请求,可是返回的响应总是无从验证该次POST请求是否成功提交了. 1. 先看下根据firebug提交的一次成功的请求,这里以login我喜欢上的xiami ...
- jsonp形式的ajax请求:
sonp形式的ajax请求:并且通过get请求的方式传入参数,注意:跨域请求是只能是get请求不能使用post请求 <!DOCTYPE html> <html> <hea ...
- EBS-如何查看非自己提交的请求的结果
http://www.cnblogs.com/quanweiru/p/4692071.html 如何查看非自己提交的请求的结果定位要找的请求SQL举例:SELECT req.request_id, ...
- EBS环境提交新请求默认是"单一请求"
http://blog.csdn.net/samt007/article/details/38304239 用过EBS的请求都知道,提交一个新报表都要点好几个按钮,其中一个很麻烦的就是选择提交新请求的 ...
- 【转】提交http请求之python与curl
提交http请求之python与curl 由于Openstack是python实现wsgi的REST ful架构,在学习和调试的过程中,常常会遇到http请求的提交,于是顺手整理下python和cur ...
随机推荐
- socket.io中文文档
socket.io 中文文档转载于:http://www.cnblogs.com/xiezhengcai/p/3956401.html 服务端 io.on(‘connection’,function( ...
- maven工具使用
一.工具安装: 所需工具 : JDK 1.8Maven 3.3.3 1.安装JDK 和 JAVA_HOME 2.添加 M2_HOME 和 MAVEN_HOME 3.添加到环境变量 - PATH 4.验 ...
- XMU 1605 nc与数列 【动态规划】
1605: nc与数列 Time Limit: 2000 MS Memory Limit: 64 MBSubmit: 84 Solved: 13[Submit][Status][Web Board ...
- Lightoj 1010 - Knights in Chessboard
1010 - Knights in Chessboard PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: ...
- SPOJ:Fibonacci Polynomial(矩阵递推&前缀和)
Problem description. The Fibonacci numbers defined as f(n) = f(n-1) + f(n-2) where f0 = 0 and f1 = 1 ...
- mongoDB 安全权限访问控制
MongoDB3.0权限 https://blog.csdn.net/leonzhouwei/article/details/46564141 转自:http://ibruce.info/2015/0 ...
- 详解Python的*args和 **kwargs
转自: http://www.python[tab].com/html/2016/pythonhexinbiancheng_0802/1057.html *args表示任何多个无名参数,它是一个tup ...
- hdu 5023(线段树区间染色,统计区间内颜色个数)
题目描述:区间染色问题,统计给定区间内有多少种颜色? 线段树模板的核心是对标记的处理 可以记下沿途经过的标记,到达目的节点之后一块算,也可以更新的时候直接更新到每一个节点 Lazy操作减少修改的次数( ...
- baiduTemplate 基本知识总结
html <div id="tem1"></div> <div id="tem2"></div> <!-- ...
- TCP/IP协议与Http协议的区别
转自:https://www.cnblogs.com/xianlei/p/tcpip_http.html TPC/IP协议是传输层协议,主要解决数据如何在网络中传输,而HTTP是应用层协议,主要解决如 ...