use of it.gmariotti.cardslib.library.view.CardListView in project cardslib by gabrielemariotti.
the class ListSectionedCardFragment method initCards.
/**
* Init
*/
private void initCards() {
//Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 200; i++) {
GooglePlaySmallCard card = new GooglePlaySmallCard(this.getActivity());
card.setTitle("Application example " + i);
card.setSecondaryTitle("A company inc..." + i);
card.setRating((float) (Math.random() * (5.0)));
card.count = i;
card.init();
//Add card to array
cards.add(card);
}
//Standard array
CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
// Sections code.
// Add the card sections
List<GplayCardSection> sections = new ArrayList<GplayCardSection>();
sections.add(new GplayCardSection(1, "Section 1", "More"));
sections.add(new GplayCardSection(3, "Section 2", "Other"));
GplayCardSection[] dummy = new GplayCardSection[sections.size()];
//Sectioned adapter
GPlaySectionedAdapter mAdapter = new GPlaySectionedAdapter(getActivity(), mCardArrayAdapter);
mAdapter.setCardSections(sections.toArray(dummy));
CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_gplaycard);
if (listView != null) {
listView.setExternalAdapter(mAdapter, mCardArrayAdapter);
}
}
Aggregations