Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
236 views
in Technique[技术] by (71.8m points)

android - R.java can't be modified

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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..


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...