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"
/>
<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、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/” 仔细看看
[解决办法]