parse R.java class

2019-09-22 01:57发布

问题:

When I'm in an activity, how can I get die complete code of the R.java class to parse it? I want to parse for a resource String.

In my R class there's the following entry:

public static int abs__home=0x7f04000a;

And I want to search the whole text of R.java for the String "abs__home". I really need to search for the string.

回答1:

Use getIdentifier()

int id = getResources().getIdentifier("abs__home", "string", getPackageName());

if the name (abs__home) does not exits inside the resources, you will get 0