簡體   English   中英

如何創建單選按鈕組?

[英]How to create radio group of a real buttons?

我想創建一個“真實”按鈕的按鈕組嗎? 我想向用戶顯示包含他的參加選項的按鈕:是,否和Meybe。 我想使用按鈕進行顯示。 怎么做?

只需在drawable文件夾中創建選擇器xml文件

checkbox_background.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
      <item android:state_checked="true" android:drawable="@drawable/checkbox_active" />
      <item android:state_checked="false" android:drawable="@drawable/checkbox_inactive" />
</selector>

並將此背景應用於您的單選按鈕

 <RadioButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/checkbox_background" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM