There is a program. It is necessary that when reading a line, the program shows a certain picture.

Ie if:

String img = "orangejuice" 

then the program will do the following:

 ImageView tvImage = (ImageView) convertView.findViewById(R.id.imageView) tvImage.setImageResourse("R.drawable." + img) 

This, logically, will not work. How do I modify the tvImage.setImageResourse("R.drawable." + img) to make it work?

    1 answer 1

    Try this

     String img = "orangejuice"; int resID = getResources().getIdentifier(img , "drawable", getPackageName()); 
    • does not work. I already saw this on Stackoverflow. More precisely does not work. "getResources ()". Can't find it - Antonio112009
    • Ahhh. In my case, you need v.getResources () ... - Antonio112009