2014-03-18 37 views
2

我收到此錯誤的幫助:我需要在XML錯誤(新手)

錯誤:錯誤:No resource found that matches the given name (at 'text' with value '@string/_____').

我改變了字符串名稱很多時間,但我仍然得到它。我的代碼有什麼問題?它正在工作,但現在它不工作。

XML:

<?xml version="1.0" encoding="utf-8"?> 

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <LinearLayout    
     android:id="@+id/topLayout" 
     android:layout_width="fill_parent"    
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

       <EditText 
        android:id="@+id/editTextMessage" 
        android:layout_width="fill_parent" 
        android:layout_height="100dp" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentTop="true" 
        android:layout_marginTop="20dp" 
        android:ems="10" 
        android:hint="@string/message" 
        android:singleLine="false" > 

        </EditText> 

       <EditText 
        android:id="@+id/editTextNumber" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="40dp" 
        android:layout_below="@+id/editTextMessage" 
        android:ems="10" 
        android:inputType="phone" > 
       </EditText> 

       <Button 
        android:id="@+id/buttonContact" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignBaseline="@+id/editTextNumber" 
        android:layout_alignBottom="@+id/editTextNumber" 
        android:layout_alignParentRight="true" 
        android:text="@string/contact" /> 

       <Button 
        android:id="@+id/buttonTimePickup" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentLeft="true" 
        android:layout_below="@+id/buttonContact" 
        android:layout_marginTop="40dp" 
        android:text="@string/time" /> <--- the error appears on this line 

       <Button 
        android:id="@+id/buttonDatePickup" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignBaseline="@+id/buttonTimePickup" 
        android:layout_alignBottom="@+id/buttonTimePickup" 
        android:layout_alignParentRight="true" 
        android:layout_marginTop="40dp" 
        android:text="@string/date" /> <-- the error appears on this line 

       <TextView 
        android:id="@+id/textView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentLeft="true" 
        android:layout_below="@+id/buttonDatePickup" 
        android:layout_marginTop="40dp" 
        android:text="@string/frequency" <--the error appears on this line 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:textSize="25sp" /> 

       <RadioGroup 
         android:id="@+id/radioGroup" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:orientation="vertical" 
         android:layout_below="@+id/textView1" 
         android:layout_centerHorizontal="true" 
         android:layout_marginTop="20dp"> 

         <RadioButton 
          android:id="@+id/oneTime" 
          android:layout_width="160dp" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:text="@string/onetime" /> < error appears on this line 

         <RadioButton 
          android:id="@+id/fifteenMinutes" 
          android:layout_width="160dp" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:text="@string/fifteen" /> <-- error appears on this line 

         <RadioButton 
          android:id="@+id/halfHour" 
          android:layout_width="160dp" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:text="@string/halfhour" /> <-- error appears on this line 

         <RadioButton 
          android:id="@+id/hour" 
          android:layout_width="160dp" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:text="@string/anhour" /> <-- error appears on this line 

         <RadioButton 
          android:id="@+id/halfDay" 
          android:layout_width="160dp" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:text="@string/halfday" /> <-- error appears on this line 

         <RadioButton 
          android:id="@+id/daily" 
          android:layout_width="160dp" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:text="@string/daily" /> <-- error appears on this line 

         <RadioButton 
          android:id="@+id/weekly" 
          android:layout_width="160dp" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:text="@string/week" /> <-- error appears on this line 

         <RadioButton 
          android:id="@+id/monthly" 
          android:layout_width="160dp" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:text="@string/month" /> <-- error appears on this line 

         <RadioButton 
          android:id="@+id/Yearly" 
          android:layout_width="160dp" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:text="@string/year" /> <-- error appears on this line 

       </RadioGroup> 

       <Button 
        android:id="@+id/buttonConfirm" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:layout_below="@+id/radioGroup" 
        android:layout_marginTop="40dp" 
        android:text="@string/confirm" /> <-- error appears on this line 

      </RelativeLayout> 

     </LinearLayout> 

    </ScrollView> 

我卡在這一個。

+0

如果你已經確認你的'strings.xml'中有正確的值,那麼[嘗試清理你的項目](http://stackoverflow.com/questions/17371281/element-type-button-must-be-隨後逐任一屬性的規範 - 鄰/ 17371305#17371305) – codeMagic

回答

4

進入水庫>值 - > strings.xml中,並添加下一行內:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <string name="time">time</string> 
    <string name="date ">date</string> 
    .............. etc for each string resource that you need 
</resources> 
0

檢查的strings.xml文件,以確保它有一個名爲「時間」值。

之後,有時當您編輯您的資源文件之一時,您需要重建項目。這將重新創建R. *文件,您的ide和xml解析器將檢查您是否確實有一個名爲該字符串的字符串。

希望有所幫助。

1

res/values/strings.xml:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 

    <string name="time">time</string> 

    <string name="date">date</string> 

    <string name="frequency">frequency</string> 

    <string name="onetime">onetime</string> 

    <string name="fifteen">fifteen</string> 

    <string name="halfhour">halfhour</string> 

    <string name="anhour">anhour</string> 

    <string name="halfday">halfday</string> 

    <string name="daily">daily</string> 

    <string name="week">week</string> 

    <string name="month">month</string> 

    <string name="year">year</string> 

    <string name="confirm">confirm</string> 

</resources> 

添加這些XML代碼,如果你所得到的錯誤:No resource found that matches the given name (at 'text' with value '@string意味着你是不是指的名字到String.Just添加這些字符串names.Then就不會發生了。