2017-02-15 11 views
0

RadioGroupに問題があります。何らかの理由で、自分のRadioButtonのIDを見つけることができません。RadioGroupで指定された名前と一致するリソースが見つかりません

エラー:

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

マイコード:

<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> 

だから、私にerrrorを与えている行がある:

android:checkedButton="@id/euro1"> 

のRadioButtonがちょうど下のことを持っているにもかかわらず、正確なID。私は間違って何をしていますか?ありがとう。

答えて

0

android:checkedButton="@id/euro1">をラジオグループに使用することはできません。

各ラジオボタンにandroid:checked="false"を追加します。未チェックのボタンについては

<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"/> 

:あなたは、チェックandroid:checked="true"

等を添加確認ボタンにしたい方

<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"/> 

ラジオグループ

からandroid:checkedButton="@id/euro1">これを削除することが

+0

を役に立てば幸いありがとう。私は問題を解決するために、idにプラスを追加することで解決しました。アンドロイド:checkedButton = "@ + id/euro1"。私はあなたも同様に働いていたと思います! – Jesper

関連する問題