2012-03-30 15 views
2

Ich versuche, eine Gruppenaktivität mit dem Radio-Widget zu machen. Mein Problem ist, dass ich nicht scheinen kann, um das Lautsprecher-Symbol zu löschen, die mit dem Radioknopf kommen, jede Hilfe wäre toll danke.Benutzerdefinierte Radio Gruppe

http://img715.imageshack.us/img715/3131/helpnj.png

<?xml version="1.0" encoding="utf-8"?> 
<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/radioGroup1" 
    android:layout_width="match_parent" 
    android:layout_height="55dp" android:background="@drawable/tilte2"> 



    <RelativeLayout 
     android:id="@+id/relativeLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 


     <RadioButton 
      android:id="@+id/radioButton1" 
      android:layout_width="105dp" 
      android:layout_height="fill_parent" 
      android:layout_alignParentRight="true" 
      android:layout_centerVertical="true" 
      android:background="@null"/> 

     <RadioButton 
      android:id="@+id/radioButton3" 
      android:layout_width="105dp" 
      android:layout_height="fill_parent" 
      android:layout_alignParentLeft="true" 
      android:layout_centerVertical="true" 
      android:background="@null"/> 

     <RadioButton 
      android:id="@+id/radioButton2" 
      android:layout_width="105dp" 
      android:layout_height="fill_parent" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true" 
      android:background="@null"/> 

    </RelativeLayout> 

</RadioGroup> 

Antwort

12

Wenn Sie das Optionsfeld ..

einen Selektor xml (radio_btn_selector.xml) im ziehbar Ordner erstellen aussehen anpassen wie.

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:drawable="@drawable/pressed_image" 
    android:state_pressed="true"/> 
<item android:drawable="@drawable/checked_image" 
    android:state_checked="true"/> 
<item android:drawable="@drawable/focused_image" 
    android:state_focused="true" /> 
<item android:drawable="@drawable/default_image" /> 
</selector> 

verwenden nun die Wähler als Button-Typ in der Radio-Button.

<RadioButton 
      android:id="@+id/radioButton2" 
      android:layout_width="105dp" 
      android:layout_height="fill_parent" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true" 
      android:background="@null" 

android:button="@drawable/radio_btn_selector" />

+0

Nice one !!! +1 für die richtige Antwort – Zoombie

0

Warum ein ToggleButton nicht stattdessen verwenden? Ein RadioButton ohne das Symbol ist wie ein ToggleButton :)

Verwandte Themen