本文主要是介绍Radio Buttons,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
<?xml version="1.0" encoding="utf-8"?> <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="wrap_content"android:orientation="vertical"><RadioButton android:id="@+id/radio_pirates"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/pirates"android:onClick="onRadioButtonClicked"/><RadioButton android:id="@+id/radio_ninjas"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/ninjas"android:onClick="onRadioButtonClicked"/> </RadioGroup>
Note: The RadioGroup
is a subclass of LinearLayout
that has a vertical orientation by default.
Tip: If you need to change the radio button state yourself (such as when loading a savedCheckBoxPreference
), use the setChecked(boolean)
or toggle()
method.
》 单选框(RadioButton),复选框(CheckBox)是所有用户界面中最普通的UI组件
这篇关于Radio Buttons的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!