I have a class called PlayerList, in in that class i have an ArrayList defined like this :
private ArrayList<Bitmap> images = new ArrayList<Bitmap>();
Now, an ArrayList remove method can exept 2 arguments, an index and an Object.
I’m trying to remove a Bitmap from the array by sending the Bitmap to it. The thing is the bit map is made of the same image but the instace of the Bitmap i saved in the array is not the same i’m trying to find, when i print the ArrayList to console i see new names all the time, stuff like :
[android.graphics.Bitmap@44ea2d48, android.graphics.Bitmap@44ea2e20]
Could this be related? and while wer’re at it, The class implements Parcelable so the data being read/writen back and forth, that can’t be too healthy too, right?
Am i missing a generic problem or it’s code specific and i should publish my code?
My problem here basiclly is when i try to remove the Bitmap, it allways removes the wrong item in the arraylist, always 1 before the 1 i need
Unless you have a handle to the
BitMap'shash code or a like key based on which it is stored, you can’t remove a desired one from the list. If you just want to depend onBitMapstored, you need to traverse through the list and parse elements to find desired bitmap. Again you need a hascode to identify if theBitMapyou are parsing is what you are looking for. Meaning you need to maintain a list ofhashcode'sfor each of theBitMapstored. Alternatively useHashMapoverListthat allows to store akeyagainst aBitMapbeing stored. And you can process your requirement based on thekeyand use it whenever required to remove aBitMapfrom theHashMaptable.