建了个工程叫helloandroid。res里面的layout文件代码如下<LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="161dp"
        android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
        
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/activity_main_title"/>
            <Button
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/continue_lable"/>
            <Button
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/new_game_lable"/>
            <Button
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/about_lable"/>
            <Button
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/exit_lable"/>
        
    </LinearLayout>
调试后出现这样的错误:[2012-12-03 19:54:13 - helloandroid] G:\JAVA\myeclipse源文件\helloandroid\res\menu\activity_main.xml:3: error: Error: No resource found that matches the given name (at 'title' with value '@string/menu_settings').
我大概能够看到好像是一个menu文件夹下的activity_main.xml文件不对劲。又不知道怎么搞,高手指点一下这是什么文件,怎么设置?这是我menu下的代码:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >    <item
        android:id="@+id/menu_settings"
        android:orderInCategory="100"
        android:showAsAction="never"
        android:title="@string/menu_settings"/></menu>

解决方案 »

  1.   

    res/valus/strings
    里面没有对menu_settings进行设置吧
      

  2.   

    应该是对的,
    android:title="@string/menu_settings"
    改成androi:title="文字"也可以的
      

  3.   

    你可以先将android:title="@string/menu_settings"
    改成android:title=“随便写点什么”看是否不会报错如果不报错就是你的资源问题
      

  4.   

    在工程目录下res-values的strings.xml文件下添加menu_settings的value值。
      

  5.   

    谢谢大侠,不过我想知道为什么要在string.xml文件夹下添加menu,string.xml文件是干什么的?
      

  6.   

       比如说在xml中添加控件text的时候(android:text=""),就可以用string.xml文件(android:text="@string/menu_settings").如果直接写(android:text="菜单")也没错,但是旁边会有一个黄色感叹号。google推荐我们写在string.xml文件中。以便以后维护,优化逻辑思想。