I need to add an image into "item". item is an xml file with TextView...
item = new ArrayList<String>();
item.add("an image");
Try this code
ArrayList<Bitmap> mBit = new ArrayList<Bitmap>(9);
for (int i = 0; i < 9; i++)
{
mBit.add(Bitmap.createBitmap(bitmapOrg, (i % 3) * newWidth, (i / 3) * newHeight, newWidth, newHeight));
}
Collections.shuffle(mBit);
for (int i = 0; i < 10; i++)
{
Bitmap bitmap = mBit.get(i));
//Do something here
}
You should create an ArrayList of objects and you can put everything you want in it and manipulate like this :
ArrayList<Object> array = new ArrayList<Object>();
array.put(0,"A string");
array.put(1,yourbitmap);
String string = (String) array.get(0);
Bitmap bitmap = (Bitmap) array.get(1);
You must cast when you get get because it is an object array.
ArrayList<String>can only hold Strings. You can store, say, the path to the image as a string, or perhaps the image itself encoded in base64. Which are you trying to do? If it's the latter, make it an ArrayList<File> or ArrayList<Image>.