Issue
I have in my database a column that stores the filename of the images I'm using in the android application. In most of my activities I need to use a lot of these images.
So I store these filenames in an ArrayList<String>
and I want for my output to be an ArrayList<Integer>
of Resources IDs of these images.
Based on several questions here on stackoverflow, I used the following technique (got it from this question) :
// Where tileImageFilenames is the ArrayList<String>
for(int i=0;i<tileImagesFilename.size();i++)
{
tileImagesIDS.add(getResources().getIdentifier(tileImagesFilename.get(i) , "drawable", getApplication().getPackageName()));
}
This returns me an ArrayList<Integer>
full of 0s.
Solution
you must create new object and then add it to your ArrayList<Integer>
for(int i=0;i<tileImagesFilename.size();i++)
{
String name = tileImagesFilename.get(i).replace(".jpg","");
tileImagesIDS.add(new Integer(getResources().getIdentifier(name , "drawable", getApplication().getPackageName())));
}
Answered By - mmlooloo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.