cardslib icon indicating copy to clipboard operation
cardslib copied to clipboard

CardListView don't display images

Open dzordz55 opened this issue 9 years ago • 1 comments

I have a problem with displaying images in CardListView. Cards looks like below:

screenshot_2015-07-17-15-34-45

This is my layout with CardListView. If it's important, layout is in SlidingUpPanelLayout view from https://github.com/umano/AndroidSlidingUpPanel

<it.gmariotti.cardslib.library.view.CardListView
        android:id="@+id/cardlistview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        style="@style/list_card.thumbnail"
        card:list_card_layout_resourceID="@layout/list_card_thumbnail_layout" />

My custom card layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"
          android:padding="10dp" >

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/card_thumbnail_image"/>

<TextView
    android:id="@+id/card_main_inner_simple_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/card_main_inner_secondary_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Cardslib"
    android:textAppearance="?android:attr/textAppearanceMedium" />

And code where I add images:

ArrayList<Card> cards = new ArrayList<>();

    for(int i = 0; i < data.size(); i++)
    {
        Card card = new Card(getActivity(), R.layout.card_layout);
        card.setBackgroundColorResourceId(R.color.colorCard);

        CardThumbnail thumb = new CardThumbnail(getActivity());
        thumb.setDrawableResource(R.drawable.ic_delete);

        card.addCardThumbnail(thumb);
        cards.add(card);
    }

    CardArrayAdapter cardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
    CardListView listView = (CardListView) getView().findViewById(R.id.cardlistview);
    if (listView != null)
        listView.setAdapter(cardArrayAdapter);

    cardArrayAdapter.notifyDataSetChanged();

dzordz55 avatar Jul 17 '15 13:07 dzordz55

I got the same problem once. I overcame this by using CardRecyclerView instead of CardListView.

safakadir avatar Aug 19 '15 07:08 safakadir