开发者

how do you find out what android resource is 0x7f040000 in eclipse?

Over the course of programming I get errors that give a resource number like "0x7f040000" (or sometimes in decimal form) My question is simple: Is there an easy way to tell what resource that is in eclipse?

i know i could manually identify every resource and print t开发者_开发百科hem out, but then every time i make a change to the program i'd have to update this code. Is there some way to search by resource ID?


YOu look up the R class in the gen folder

for example

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int block=0x7f020000;

block is part or the drawables in the R file.

if you want to do this at runtime (and not just in the IDE of eclispe you can try

getResources().getResourceName(id);


you can use getResources() for that:

getResources().getResourceName( theID )


In your project structure, you should have a directory called gen. Browse that directory until you find the class R. There you find every resource of your project defined.

Another possibility is to go directly to the R class: Press ctrl + shift + T and in the popup you just type R. But be careful: There are at least two R classes listed there. One is from Android itself (package android.R) and your with the package name you have chosen.


Look at your R class and see what variable corresponds to that resource id. Right click -> Go To Definition.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜