我需要帮助xml错误(新手)

时间:2014-03-18 21:32:42

标签: android 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>

我坚持这个。

2 个答案:

答案 0 :(得分:4)

转到res-&gt; values-&gt; 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>

答案 1 :(得分:1)

res/values/strings.xml:

中添加这些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>

如果您收到错误:No resource found that matches the given name (at 'text' with value '@string表示您没有将名称引用到String.Just添加这些String名称。然后它就不会发生。