当前位置:网站首页>RadioGroup(单选框)
RadioGroup(单选框)
2022-07-27 17:02:00 【Ashurol】
public class MainActivity extends ActionBarActivity implements OnCheckedChangeListener{
RadioGroup rp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rp=(RadioGroup) findViewById(R.id.radioGroup1);
rp.setOnCheckedChangeListener(this);
}
@Override
public void onCheckedChanged(RadioGroup arg0, int CheckedId) {
// TODO Auto-generated method stub
switch(CheckedId)
{
case R.id.radio0:
Toast.makeText(this, "你是男孩", Toast.LENGTH_SHORT).show();
break;
case R.id.radio1:
Toast.makeText(this, "你是女孩", Toast.LENGTH_SHORT).show();
break;
}
}
}记得别导包android.widget.RadioGroup.OnCheckedChangeListener<pre name="code" class="html"><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.xin.radiogroup.MainActivity" >
<RadioGroup
android:id="@+id/radioGroup1"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="14dp" >
<RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="男" />
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="女" />
</RadioGroup>
</RelativeLayout>

边栏推荐
- 全球手机芯片设计领域首家!紫光展锐荣膺TMMi4级国际认证
- 嵌入式C语言对次数固定的循环的优化
- 零知识证明的硬件加速
- 传苹果计划以2亿美元购买JDI部分工厂
- Incluxdb series (III) detailed explanation of incluxdb configuration file
- C language: 12. GDB tool debugging C program
- [Huawei cloud stack] [shelf presence] issue 13: have you seen the decoupling architecture of the management area? Help government and enterprise customers solve big problems
- Big guys, Oracle CDC, local operation, always encounter this an exception occurred in
- 【华为云Stack】【大架光临】第13期:管理区解耦架构见过吗?帮政企客户搞定大难题
- HDU1323_Perfection【水题】
猜你喜欢

rxbinding

C language: 15. Structure

带来高价值用户体验的低代码开发平台

jvisualvm的使用

Make your chat bubbles colorful

应用程序池已被禁用

c语言:12、gdb工具调试c程序
![[basic knowledge of deep learning - 46] Bayesian theorem and conditional probability formula](/img/9f/b9d7503404e068495fd8613df29366.png)
[basic knowledge of deep learning - 46] Bayesian theorem and conditional probability formula

C language: 8. Makefile preparation

A low code development platform that brings high-value user experience
随机推荐
OPPO发布首款AR眼镜,宣布未来3年投入500亿进行研发
[basic knowledge of deep learning - 46] Bayesian theorem and conditional probability formula
Count the six weapons of the domestic interface cooperation platform!
IEC104 规约详细解读(一) 协议结构
英特尔未来10年工艺路线图曝光:2029年推出1.4nm工艺!如何实现?
【深度学习基础知识 - 49】Kmeans
influxDB系列(三)influxDB配置文件详解
【深度学习基础知识 - 42】逻辑回归详解
【华为云Stack】【大架光临】第13期:管理区解耦架构见过吗?帮政企客户搞定大难题
27、golang基础-互斥锁、读写锁
【深度学习基础知识 - 37】解决正负样本不均衡 Focal Loss
Oppo released the first AR glasses and announced that it would invest 50billion in research and development in the next three years
王牌代码静态测试工具Helix QAC 2022.2中的新增功能(2)
The first in the field of mobile phone chip design in the world! Ziguang zhanrui won the international certification of tmmi4
IIS 发生未知FastCGI错误:0x80070005
High cost, difficult to implement, slow to take effect, what about open source security?
Intel releases horse ridge chip: 22nm process, which can control multiple qubits
Flink 算子简介
【深度学习基础知识 - 46】贝叶斯定理与条件概率公式
Summary of APP launch in vivo application market