简体   繁体   中英

Why should I use the R.id, as opposed to the code it generates?

I mean, besides code cleanliness, is it a preference, or a taboo? I'm just curious.

For instance:

public static final class layout {
public static final int main=0x7f030000;

why not use "0x7f030000" instead of "R.id.main"?

The IDs generated in R.id are not static. Any additional IDs you add to any of your XML files may change previously generated values. Therefore you should always use R.id.your_id as those are static.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM