Search element by name

The question was asked: 6 years 10 months ago   views: 16

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: Nicolas Chabanovsky Nicolas Chabanovsky 10-04-2012 в 09:22:04

Answers   1


It is necessary a little differently:

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