Android UI教程 - Android RelativeLayout

2018-01-09 14:51 更新

Android UI教程 - Android RadioButton


一個(gè)單選按鈕給用戶幾個(gè)選擇和用戶只能選擇一個(gè)項(xiàng)目。

單選按鈕通常屬于一個(gè)組,并且每個(gè)組只能有一次選擇一個(gè)項(xiàng)目。

要在Android中創(chuàng)建一組單選按鈕,首先創(chuàng)建一個(gè) RadioGroup ,然后使用單選按鈕填充組。

例子

在Android中,您使用 android.widget.RadioGroup 實(shí)現(xiàn)一個(gè)單選組和無(wú)線電按鈕使用 android.widget.RadioButton

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">

    <RadioGroup
        android:id="@+id/rBtnGrp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <RadioButton
            android:id="@+id/chRBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="XML" />

        <RadioButton
            android:id="@+id/fishRBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="HTML" />

        <RadioButton
            android:id="@+id/stkRBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="CSS" />

    </RadioGroup>

</LinearLayout>
null


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)