Search element by name

The question was asked: 7 years 4 months ago   views: 31

Need to find the element by name. Found in the documentation of this decision. But the problem is that getResource returns me always zeros in this case:

int z = getResources().getIdentifier("R. drawable.bag", "String", getPackageName());

If I ask picture standard:

IvLogo ImageView = (ImageView) findViewById(R. id.imageViewLogoV); ivLogo.setImageResource(R. drawable.bag);

then everything is displayed correctly. What's the problem?

Asked: 10-04-2012 в 09:22:04

Answers   1


It is necessary a little differently:

int z = getResources().getIdentifier("bag", "Drawable", getPackageName());
Answered: 10-04-2012 в 10:40:05
Thank you. Can't + do not have enough reputation :( - 10-04-2012 в 16:59:15