我的android工程里面,在/res/layout/sub.xml里面写了一个Button和Text    <EditText
        android:id="@+subId/otherActivityDate"
        android:layout_width = "fill_parent"
        android:layout_height = "wrap_content"
        />
    <Button 
        android:id = "@+subId/return_parentBtn"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="return your other View"
        />
我觉得,这个<Button>里面的id取名return_parentBtn,我个人感觉不形象,于是,我将Button的id改名叫
return_otherBtn
接着,我点击Ctrl+S保存文件,之后,发现,R类没有变化 !!!!!!!百度了很久,之后,根据百度的建议,我选择了Eclipse中“clean”,选中“clean projects selected below”!之后,R类不见了!!!
之后,重启了n变Eclipse,照旧
----------------以上,是我这 2 个问题的描述 ------------------
以下是我修改后的xml,请看    <EditText
        android:id="@+subId/otherActivityDate"
        android:layout_width = "fill_parent"
        android:layout_height = "fill_parent"
        />
    <Button 
        android:id = "@+subId/return_other_Btn"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="return your other View"
        />请教:
1、为什么我改了名字后R类不变 ? 【我已经 Build Automatically了】
2、为什么我clean了后R类被删掉,并且没有了 ?
3、如果修改 【这是重点】

解决方案 »

  1.   

    我自己的使用经验:
    1、Build Automatically不是每次都灵,有时还是要自己build,当前具体原因我没有去了解
    2、clean会清掉当前R,build以后会再次出现(如果你的代码没有错的话),至于为什么可能是google为了至少异常的出现吧,比如R与对象对不起神马的
    3、 google明确说明R不要自己修改(自己修改会出警告)
      

  2.   

    clean 的时候,如果你的res下有xml错误,R文件就不会自动生成。你先看看你res下有没有xml报错,如果有的话,把错改掉,再clean,就会有R文件了
      

  3.   

    clean的时候,R.JAVA会删掉重新生成,此时如果资源里有错误,就不能生成,你可以看看错误日志,应该会有提示的
      

  4.   

    id取名是不是错了  “ android:id = "@+subId/return_parentBtn"” 应该是 android:id = "@+id/return_parentBtn"  而不是  “@+sbuId/”  仔细看看   
      

  5.   


    为什么错了 ? 请指教 。 我觉得@+subId无非是增加一个自定义的static class subId{}而已,和@+id没区别吧?
      

  6.   


    我的问题中有 clean后的xml文件,我再给一次你看看<Button 
            android:id = "@+subId/return_other_Btn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="return your other View"
            />
    Eclipse在android:layout_height这里报了错,但是,我打一个空格键再ctrl+S保存,又不报错了!
    所以很怪!求教!!!
      

  7.   

    我的问题中有 clean后的xml文件,我再给一次你看看<Button 
            android:id = "@+subId/return_other_Btn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="return your other View"
            />
    Eclipse在android:layout_height这里报了错,但是,我打一个空格键再ctrl+S保存,又不报错了!
    所以很怪!求教!!!
      

  8.   


    为什么错了 ? 请指教 。 我觉得@+subId无非是增加一个自定义的static class subId{}而已,和@+id没区别吧?
    哦  原来是自定义id  那就是我弄错了  不好意思  误导你啦。 为什么要自定义一个类啊  没用过  求指教
      

  9.   

    你的id 为什么是 @+subId/
    你直接用@+id看呢
      

  10.   


    为什么错了 ? 请指教 。 我觉得@+subId无非是增加一个自定义的static class subId{}而已,和@+id没区别吧?
    哦  原来是自定义id  那就是我弄错了  不好意思  误导你啦。 为什么要自定义一个类啊  没用过  求指教我是初学者,上礼拜开始学android,说来别见笑!
    我之所以@+subId的理由如下:
    @是一个引用
    @+是增加一个引用,
    每一次@+name,android就会在R类里面自动生成一个static class name{...}的内部类
    由于我的MainActivity里面需要引用id的,
    所以,我的OtherActivity引用东西就要跟MainActivity区分开来,所以我定义了subId