1

How can I populate the image switcher dynamically, when I have the images in the drawable folder and sub folder .. like drawable-ldpi/S_001/a001_001.jpg.

I have tried to populate one image, but the application crashed. Here is the code:

ImageSwitcher imageSwitcher = (ImageSwitcher) findViewById(R.id.imageSwitcher);
imageSwitcher.setImageDrawable(getResources().getDrawable(getResources().getIdentifier("S_001/a001_001.jpg", "drawable", getPackageName())));

I need some assisstance.

user2199343
  • 1,883
  • 3
  • 13
  • 9

1 Answers1

1

drawables folder is for img resources used by your app, like icons, 9-patches, backgrounds and other ui elements. You can't put subdirectories there.

If you plan to use some photos in an ImageSwitcher or anything like this, you should use assets folder. Read this to find out more.

Community
  • 1
  • 1
Michał Klimczak
  • 12,674
  • 8
  • 66
  • 99