I'm using a CardListView with CardThumbnail. I'm retirieving each CardView information from an sqlite database row which has a BLOB field (used to store images). As shown in this picture, after filling CardListView from database, everything seems to be fine except for the CardThumbnail. It only shows the last iterated database row Bitmap field in every CardView of the list.
I'm using this code to iterate every sqlite row and fill CardListView items :
/* Retrieving items from database */
List<Item> items = dataBase.getAllItemsLOC();
int itemsLOCCount = items.size();
/* Iterating retrieved database items */
for (int i = 0; i < itemsLOCCount; i++) {
final Item item = items.get(i);
RentCard card = new RentCard(getActivity());
/* Add thumbnail */
CardThumbnail cardThumbnail = new CardThumbnail(getActivity());
cardThumbnail.setCustomSource(new CardThumbnail.CustomSource() {
@Override
public String getTag() {
return "com.google.android.apps.maps";
}
@Override
public Bitmap getBitmap() {
Bitmap bitmap = item.getImageBitmap();
return bitmap;
}
});
card.addCardThumbnail(cardThumbnail);
card.setDevise(item.getDevise());
/* ... setting the rest of the CardView properties ... */
card.setId("" + items.get(i).getId());
cards.add(card);
}
mCardArrayAdapter.notifyDataSetChanged();
Could you please help me identify the problem?
Aucun commentaire:
Enregistrer un commentaire