当前位置:网站首页>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>

边栏推荐
- 【华为云Stack】【大架光临】第13期:管理区解耦架构见过吗?帮政企客户搞定大难题
- [basic knowledge of deep learning - 50] PCA dimensionality reduction principal component analysis
- 5W奖金池/面向高校,2022法律科技创新大赛报名火热进行中
- 开启和禁用hyper-v
- S32K系列芯片--简介
- Intel releases horse ridge chip: 22nm process, which can control multiple qubits
- Introduction to several wireless protocols
- Embedded C language loop deployment
- Adhering to the integration of software and hardware, one Hengke makes efforts to the intelligent educational robot market
- jvisualvm的使用
猜你喜欢

C language: 10. Input stream, output stream, error stream

C language: 8. Makefile preparation

Tab control of MFC advanced control (CTabCtrl)

c语言:12、gdb工具调试c程序

golang设置国内镜像,vscode配置golang开发环境,vscode调试golang代码

A low code development platform that brings high-value user experience

jvisualvm的使用

正十七边形尺规作图可解性复数证明

Embedded C language structure

c语言:c语言代码风格
随机推荐
【深度学习基础知识 - 49】Kmeans
High cost, difficult to implement, slow to take effect, what about open source security?
王牌代码静态测试工具Helix QAC 2022.2 中的新增功能(1)
【日常积累 - 06】查看cuda和cudnn版本
英特尔发布Horse Ridge芯片:22nm工艺,能够控制多个量子位
王牌代码静态测试工具Helix QAC 2022.2中的新增功能(2)
Map和Set
A lock faster than read-write lock. Don't get to know it quickly
[basic knowledge of deep learning - 45] distance calculation methods commonly used in machine learning
Low code implementation exploration (45) business parameters
记一次无准备的实习面试
MFC高级控件之Tab控件( CTabCtrl )
Debian recaptured the "debian.community" domain name, but it's still not good to stop and rest
Optimization of embedded C language for indefinite cycles
Come to sword finger offer 03. Repeated numbers in the array
Basic network faults and troubleshooting
TSMC 5nm is about to mass produce: Apple A14 monopolizes 70% of the production capacity, and Huawei Kirin 1020 takes 30%
C language: 7. How to use C language multi source files
Intel's process roadmap for the next 10 years is exposed: 1.4nm process will be launched in 2029! How?
The first in the field of mobile phone chip design in the world! Ziguang zhanrui won the international certification of tmmi4