R.java can't be modified

白昼怎懂夜的黑 提交于 2019-12-17 22:28:19

问题


I was trying to modify the R.java in android. I deleted the generated java files. After saving, it doesn't seem to change anything. The R.java file i have looks like this

/* 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;
}
}

I wanted to change it, to be more like this one:

 /* 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;
}
}

It so frustrating every time I save it, it goes back to its old state because it's auto generated . How do I modify it?


回答1:


R.java is an auto generated file contains all your resources used in project. If you want to change R.java you can't.

You have to add or delete resources, then it will be modified according to your resources present in project.

This is basic thing in Android. You have to read Android Developers documents, then you will get good knowledge about it.




回答2:


You cannot modify R.java in android it will be generated automatically when we are developing an xml file.... here id numbers will be stored of different views so we can't modify it..



来源:https://stackoverflow.com/questions/8615007/r-java-cant-be-modified

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!