导航:首页 > 操作系统 > android单选按钮

android单选按钮

发布时间:2022-03-31 15:48:16

Ⅰ 安卓开发 单选对话框实现跳转

AlertDialog Builder=new AlertDialog.Builder(Aone.this).setTitle("单选框")
.setSingleChoiceItems(
new String[] { "青少年", "成年人","中年人","老年人" }, 0,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// dialog.dismiss();
//这里就是你要写的地方onclick()里面的which就是你点击单选框的索引
//如果你想点击青少年的时候跳转,就判断一下
if(which==0){
Intent objIntent = new Intent();

。。。。就不写了

}
}
}).setNegativeButton("确定", null).show();

android 编程中怎样从单选按钮获取数据

java">this.sex=(RadioGroup)super.findViewById(R.id.sex);
this.male=(RadioButton)super.findViewById(R.id.male);
this.female=(RadioButton)super.findViewById(R.id.female);
this.sex.setOnCheckedChangeListener(newOnCheckedChangeListenerImp());

r{

publicvoidonCheckedChanged(RadioGroupgroup,intcheckedId){
Stringtemp=null;
if(MainActivity.this.male.getId()==checkedId){
temp="男";
}
elseif(MainActivity.this.female.getId()==checkedId){
temp="女";
}

RadioButton是android开发中常见的一种控件,而使用简单,通常与RadioGroup一起使用。RadioButton表示单个圆形单选框,而RadioGroup是可以容纳多个RadioButton的容器。

Ⅲ android开发 如何在Activity中更改单选按钮默认值比如一开始默认是男,选择女后想再次选择使默认是女

在单选按钮控件的setOnCheckChangeListenner方法中,获取到选择的是男是女以后,将值存入SharePreference,下次从中再取出来

Ⅳ Android Studio 单选按钮

是的,没错,能单独拿出来拿出来用,要用RadioGroup包起来,代表一个组嘛,道理很简单。CheckBox可以单独出来。

用法是这样的

<RadioGroup....>
<RadioButton.../>
<RadioButton.../>
<RadioButton.../>
<RadioButton.../>
......
</RadioGroup>

Ⅳ Android studio 单选按钮怎么更改点击后的样式

button设置null之后再设置background,自己创建个selector就行了

Ⅵ 问一下 android radiobutton控件 控制单选按钮和文字之间的距离的问题

我觉得RadioButton原始的button如果设置为 android:button="@null“ 而用android:drowableLeft=”@drawable/radiobtn_selector“;这样显示图片的话效果会更加好,而且可以用android:drawablePading=”10dp“这个属性控制图片和字儿的距离。

希望可以帮到你。Thanks

Ⅶ android 用imageview实现单选功能

imageView2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
v.setBackgroundResource(null); v.setBackgroundResource(R.drawable.adddoorbellon);
ImageView imageView = (ImageView) findViewById(R.id.yimenling_oneclick);
imageView.setBackgroundResource(R.drawable.akeyconfiguration);
}
});

这样试试,,最好把你的错误日志发出来

Ⅷ android radiobutton怎么单选

activity_main.xml

<RadioGroup

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="horizontal"

android:layout_gravity="center_horizontal">

<RadioButton

android:id="@+id/xiaoxi"

android:layout_weight="1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="消息"

android:button="@null"

android:textSize="20sp"

android:gravity="center"

android:checked="true"

android:drawableTop="@drawable/selector_bar_1"/>

<RadioButton

android:id="@+id/lianxiren"

android:layout_weight="1"

android:button="@null"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="联系人"

android:gravity="center"

android:drawableTop="@drawable/selector_bar_2"

android:textSize="20sp"/>

<RadioButton

android:id="@+id/dongtai"

android:layout_weight="1"

android:button="@null"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:textSize="20sp"

android:gravity="center"

android:drawableTop="@drawable/selector_bar_3"

android:text="动态"/>

</RadioGroup>

---------------------------在drawable下新建文件----------------------

1.selector_bar_1.xml

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

<selectorxmlns:android="http://schemas.android.com/apk/res/android">

<itemandroid:drawable="@mipmap/bar_1_select"android:state_checked="true"/>

<itemandroid:drawable="@mipmap/bar_1_unselect"android:state_checked="false"/>

</selector>

2.selector_bar_1.xml

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

<selectorxmlns:android="http://schemas.android.com/apk/res/android">

<itemandroid:drawable="@mipmap/bar_2_selector"android:state_checked="true"/>

<itemandroid:drawable="@mipmap/bar_2_unselector"android:state_checked="false"/>

</selector>

3.selector_bar_1.xml

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

</selector>

Ⅸ 如何实现android中三个单选按钮横向排列且只能选一个

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/row_item_margin">

<TextView
android:id="@+id/tvStorageWay"
style="@style/EditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="储存方式:"/>

<RadioGroup
android:id="@+id/rgStorageWay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/tvStorageWay"
android:gravity="center_vertical"
android:orientation="horizontal">

<RadioButton
android:id="@+id/rbPack"
style="@style/EditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@null"
android:drawableLeft="@drawable/selector_login_mode_radiobutton"
android:text="包装"/>

<RadioButton
android:id="@+id/rbBulk"
style="@style/EditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/row_item_margin"
android:layout_weight="1"
android:button="@null"
android:drawableLeft="@drawable/selector_login_mode_radiobutton"
android:text="散装"/>

<RadioButton
android:id="@+id/rbStorageWayOther"
style="@style/EditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/row_item_margin"
android:layout_weight="1"
android:button="@null"
android:drawableLeft="@drawable/selector_login_mode_radiobutton"
android:text="其它"/>
</RadioGroup>
</RelativeLayout>

Ⅹ 如何将文本放在 android 中单选按钮的左边

<RadioGroup
android:id="@+id/radios"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="right"
android:inputType="text"
android:orientation="vertical">

<RadioButton
android:id="@+id/first"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="@color/white"
android:button="@null"
android:drawablePadding="30dp"
android:drawableRight="@android:drawable/btn_radio"
android:text="first"
android:textColor="@color/Black"
android:textSize="20dip"/>

<RadioButton
android:id="@+id/second"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/Black"
android:button="@null"
android:drawablePadding="30dp"
android:drawableRight="@android:drawable/btn_radio"
android:text="second"
android:textColor="@color/White"
android:textSize="20dp"/>

<RadioButton
android:id="@+id/third"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/Maroon"
android:button="@null"
android:drawablePadding="30dp"
android:drawableRight="@android:drawable/btn_radio"
android:text="third"
android:textColor="@color/Vanilla"
android:textSize="20dp"/>
</RadioGroup>

阅读全文

与android单选按钮相关的资料

热点内容
香港阿里云服务器怎么封udp 浏览:875
APp买海鲜到哪里 浏览:501
辽油社保app总提示更新怎么办 浏览:586
导入源码教程视频 浏览:613
天翼贷app在哪里下载 浏览:186
app开发源码查看器 浏览:516
程序员发展到了一个瓶颈 浏览:120
程序员去机房干嘛 浏览:697
英雄训练师怎么看曾经服务器 浏览:546
魔兽世界单机输入gm命令 浏览:372
51单片机最大负跳距是多少 浏览:418
android聊天控件 浏览:128
导致压缩机坏的原因 浏览:295
如何多次选取文件夹 浏览:280
android编译生成odex 浏览:233
我的世界联机侠服务器如何用指令 浏览:94
地铁逃生战斗服务器为什么进不了 浏览:572
加密门卡怎么模拟小米9 浏览:744
核算法 浏览:632
炸弹命令 浏览:550