我试图在android中修改R.java。我删除了生成的java文件。保存后,它似乎没有任何改变。 R.java文件我看起来像这样
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int myEditText=0x7f050000;
public static final int myListView=0x7f050001;
}
public static final class layout {
public static final int colors=0x7f030000;
public static final int dimens=0x7f030001;
public static final int main=0x7f030002;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}
我想改变它,更像是这个:
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
public final class R {
public static final class attr {
}
public static final class color {
public static final int notepad_lines=0x7f040001;
public static final int notepad_margin=0x7f040002;
public static final int notepad_paper=0x7f040000;
public static final int notepad_text=0x7f040003;
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int myEditText=0x7f050000;
public static final int myListView=0x7f050001;
}
public static final class layout {
public static final int colors=0x7f030000;
public static final int dimens=0x7f030001;
public static final int main=0x7f030002;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}
每次我保存它都会令人沮丧,它会回到旧状态,因为它是自动生成的。我该如何修改它?
答案 0 :(得分:1)
你不能在android中修改R.java它会在我们开发一个xml文件时自动生成....这里id号将存储不同的视图,所以我们不能修改它..
答案 1 :(得分:1)
R.java是一个自动生成的文件,包含项目中使用的所有资源。如果你想改变R.java你不能。
您必须添加或删除资源,然后根据项目中的资源对其进行修改。
这是Android的基本功能。您必须阅读Android开发者文档,然后您才能获得相关知识。