Need to find an item by name. Found in documentation 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 set the picture as standard:

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

then everything is displayed correctly. What is the problem?

    1 answer 1

    It should be a little different:

     int z = getResources().getIdentifier("bag", "Drawable", getPackageName()); 
    • one
      Thank. I can not + make a reputation is not enough: ( - DeMoGargon