Android——单选框和复选框
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="投票主题0"
android:textSize="24sp"
android:textColor="#1568dc"
android:textStyle="bold"/>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

本文详细介绍了Android中单选框(RadioButton)和复选框(CheckBox)的使用方法,包括XML布局文件中的声明、Java代码中的操作以及在实际应用中的常见场景。通过实例展示了如何实现单选和多选功能,帮助开发者更好地理解并掌握这两种UI组件。
最低0.47元/天 解锁文章
5953





