首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

R类不自动改变,以及R类不见了的有关问题

2013-08-06 
R类不自动改变,以及R类不见了的问题我的android工程里面,在/res/layout/sub.xml里面写了一个Button和Text

R类不自动改变,以及R类不见了的问题
我的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、Build Automatically不是每次都灵,有时还是要自己build,当前具体原因我没有去了解
2、clean会清掉当前R,build以后会再次出现(如果你的代码没有错的话),至于为什么。。。可能是google为了至少异常的出现吧,比如R与对象对不起神马的
3、 google明确说明R不要自己修改(自己修改会出警告)
[解决办法]
clean 的时候,如果你的res下有xml错误,R文件就不会自动生成。你先看看你res下有没有xml报错,如果有的话,把错改掉,再clean,就会有R文件了
[解决办法]
clean的时候,R.JAVA会删掉重新生成,此时如果资源里有错误,就不能生成,你可以看看错误日志,应该会有提示的
[解决办法]
id取名是不是错了  “ android:id = "@+subId/return_parentBtn"” 应该是 android:id = "@+id/return_parentBtn"  而不是  “@+sbuId/”  仔细看看   
[解决办法]

引用:
Quote: 引用:

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


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

哦  原来是自定义id  那就是我弄错了  不好意思  误导你啦。 为什么要自定义一个类啊  没用过  求指教
[解决办法]
你的id 为什么是 @+subId/
你直接用@+id看呢

热点排行