本文主要是介绍android - Radio Buttons,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
》 When the user selects one of the radio buttons, the corresponding RadioButton
object receives an on-click event.
<?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.
这篇关于android - Radio Buttons的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!