Question

I have a folder witch contains sub folders. There are Images in Sub Folders and the Number of Images varies from folder to folder. How i can get the List of all images from Drawable by java. following is the code for the assets folder. I want like this for Drawable

   String[] files = assetManager.list("Deaf/0"+possition);
Was it helpful?

Solution

First you need to Create int[] Array that store all your images id like:

int[] type_img=new int[]{R.drawable.img1,R.drawable.img2,R.drawable.img3,R.drawable.img4,R.drawable.img5};

And load your images into loop like:

for(int i=0;i<type_img.length();i++){
        image_view.setBackground(activity.getResources().getDrawable(type_img[i])));
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top