Click here to Skip to main content
15,302,857 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How we can get all images ids from drawable folder in an integer array at runtime?
Posted
Comments
Sudhakar Shinde 1-Apr-13 10:50am
   
Have you tried anything? May be you can use search engine to get answer to your question.

1 solution

Java
Field[] ID_Fields = R.drawable.class.getFields();
        int[] resArray = new int[ID_Fields.length];
        for(int i = 0; i < ID_Fields.length; i++)
            try {
                resArray[i] = ID_Fields[i].getInt(null);
            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    }


i use this code by the help of this code we can get the name of all images means path but how we can create the integer array using this code
   
v2
Comments
Sudhakar Shinde 2-Apr-13 1:16am
   
Can you please check what is the content of resArray by putting a logger at the end of the for loop?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900