<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:orientation="vertical">
    
    <TextView android:id="@+id/text1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textSize="24sp"
        android:text="@string/text1" />
  X  <Button android:id="@id/button1"
        android:layout_width="80sp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="@string/red" />
  X <Button android:id="@id/button2"
  X    android:layout_width="80sp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
  X      android:text="@string/green" />
    
</LinearLayout>
以上是我的xml文件的代码。前面打“X”的是报错的地方。都是同一个错误。报错是类似这样的:
No resource found that matches the given name (at 'text' with value '@string/green').小弟是新手,跪求指导

解决方案 »

  1.   

    把项目clean一下 在project里面
      

  2.   

    clean之后  R.java这个文件就不见了,报错更多,蛋碎了一地
      

  3.   

    在string.xml里面是否有定义:
    <string name="green"> </string>
    <string name="red"> </string>
      

  4.   

    <Button android:id="@+id/button1"<Button android:id="@+id/button2"
      

  5.   

    在string.xml里面加了<string name="green"> </string>
        <string name="red"> </string>
        <string name="text1"> </string>
        <string name="button1"> </string>
        <string name="button2"> </string>
    这两句<Button android:id="@id/button2"
         <Button android:id="@id/button1"
    还是报错:No resource found that matches the given name (at 'id' with value '@id/button1').
      

  6.   

    @id/  替换成 @+id/或者在values 文件夹下 新建ids.xml
    <resources>
        <item type="id" name="button1"></item>
        <item type="id" name="button2"></item>
    </resources>
      

  7.   

    @id/ 替换成 @+id/   是新加的控件的话用@+id/