2017-02-15 1 views
0

Ich habe einige Probleme mit einer RadioGroup. Aus irgendeinem Grund kann es die ID eines meiner RadioButtons nicht finden.Keine Ressource gefunden, die den angegebenen Namen mit RadioGroup

Der Fehler:

Error:(18, 32) No resource found that matches the given name (at 'checkedButton' with value '@id/euro1'). 

Mein Code:

<RadioGroup 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/betGroup" 
    android:checkedButton="@id/euro1"> 

    <RadioButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/euro1" 
     android:drawableLeft="@drawable/euromoent1" 
     android:layout_marginBottom="10dp"/> 

    <RadioButton 
     android:drawableLeft="@drawable/euromoent2" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:id="@+id/euro2" 
     android:layout_marginBottom="10dp"/> 

    <RadioButton 
     android:drawableLeft="@drawable/euro5small" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:id="@+id/euro5" 
     android:layout_marginBottom="10dp"/> 

    <RadioButton 
     android:drawableLeft="@drawable/euro10small" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:id="@+id/euro10" 
     android:layout_marginBottom="10dp"/> 

    <RadioButton 
     android:drawableLeft="@drawable/euro20small" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:id="@+id/euro20" /> 

</RadioGroup> 

So ist die Linie, die mir eine errror schenkt ist:

android:checkedButton="@id/euro1"> 

Auch wenn die RadioButton- knapp unterhalb hat, dass genaue ID Was mache ich falsch? Vielen Dank.

Antwort

0

Sie können android:checkedButton="@id/euro1"> nicht in der Radiogruppe verwenden.

Fügen Sie android:checked="false" zu jedem Ihrer RadioButtons hinzu. Unabhängig davon, welche Sie überprüfen möchten, fügen Sie android:checked="true"

Wie für aufgegebenes Taste:

<RadioButton 
    android:drawableLeft="@drawable/euro5small" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:id="@+id/euro5" 
    android:checked="true" 
    android:layout_marginBottom="10dp"/> 

Für ungehemmt Taste:

<RadioButton 
    android:drawableLeft="@drawable/euro5small" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:id="@+id/euro5" 
    android:checked="false" 
    android:layout_marginBottom="10dp"/> 

entfernen android:checkedButton="@id/euro1"> diese von Radiogroup

Hoffe, dass es

+0

hilft Vielen Dank. Ich habe das Problem gelöst, indem ich ein Plus in der ID hinzugefügt habe: Android: checkedButton = "@ + id/euro1". Ich denke, deine hätte auch funktioniert! – Jesper

Verwandte Themen