i am using image slider in my layout, for this i used
private Integer[] mImageIds = { R.drawable.j, R.drawable.f,R.drawable.i, R.drawable.g, R.drawable.k };
to take the images.But now i want to take the images from sdcard and store these images into that array.How can i do this?
below is my code. i stored thumb in database.I converted bitmap to drawable and then how to store this into Array mImages?
List<String> thumb = new ArrayList<String>();
public Integer[] mImageIds;
Bitmap bitmap;
thumb = db.getRecomdThumb();//get image address from db
for(int i = 0; i < thumb.size();i++){
bitmap = BitmapFactory.decodeFile(thumb.get(i));
Drawable d = new BitmapDrawable(getResources(),bitmap);
}
Only the images you store inside the “res” folder can be added to a Integer array. You can create a int res from dynamically created Bitmap. You can only convert it to Drawable as you have mentioned in your code.
If you ask me, will it be possible to get Int representation if I add the dynamically created drawable to res folder, it is not possible.
“Res” folder can’t be modified. It is read only.
So what you have to do is, just create a Drawable array instead of Integer array and do your operation.
Something like this would work,