use of it.gmariotti.cardslib.demo.cards.ColorCard in project cardslib by gabrielemariotti.
the class ListColorFragment method initCards.
private void initCards() {
//Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 5; i++) {
ColorCard card = new ColorCard(this.getActivity());
card.setTitle("A simple colored card " + i);
card.setCount(i);
switch(i) {
case 0:
card.setBackgroundResourceId(R.drawable.demo_card_selector_color5);
break;
case 1:
card.setBackgroundResourceId(R.drawable.demo_card_selector_color4);
break;
case 2:
card.setBackgroundResourceId(R.drawable.demo_card_selector_color3);
break;
case 3:
card.setBackgroundResourceId(R.drawable.demo_card_selector_color2);
break;
case 4:
card.setBackgroundResourceId(R.drawable.demo_card_selector_color1);
break;
}
cards.add(card);
}
CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_colors);
if (listView != null) {
listView.setAdapter(mCardArrayAdapter);
}
}
use of it.gmariotti.cardslib.demo.cards.ColorCard in project cardslib by gabrielemariotti.
the class NativeChangeValueCardFragment method initCards.
/**
* Inits the initial card
*/
private void initCards() {
card1 = new CardExample(getActivity(), "Header", "Title");
cardView1 = (CardViewNative) getActivity().findViewById(R.id.carddemo_card_changevalue_id);
cardView1.setCard(card1);
card2 = new CardExample2(getActivity(), "Header", "Title");
cardView2 = (CardViewNative) getActivity().findViewById(R.id.carddemo_card_changevalue_id2);
cardView2.setCard(card2);
card3 = new CardExample3(getActivity(), "Header", "Title");
cardView3 = (CardViewNative) getActivity().findViewById(R.id.carddemo_card_changevalue_id3);
cardView3.setCard(card3);
card4 = new ColorCard(getActivity());
card4.setTitle("A simple car");
cardView4 = (CardViewNative) getActivity().findViewById(R.id.carddemo_card_changevalue_id4);
StateListDrawable initDrawable = new StateListDrawable();
initDrawable.addState(new int[] { android.R.attr.state_pressed }, getResources().getDrawable(R.drawable.pressed_background_card));
initDrawable.addState(new int[] {}, getResources().getDrawable(R.drawable.demo_card_background_color1));
card4.setBackgroundResource(initDrawable);
cardView4.setCard(card4);
}
use of it.gmariotti.cardslib.demo.cards.ColorCard in project cardslib by gabrielemariotti.
the class NativeListColorFragment method initCards.
private void initCards() {
//Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 5; i++) {
ColorCard card = new ColorCard(this.getActivity());
card.setTitle("A simple colored card " + i);
card.setCount(i);
switch(i) {
case 0:
card.setBackgroundColorResourceId(R.color.demo_card_background_color5);
break;
case 1:
card.setBackgroundColorResourceId(R.color.demo_card_background_color4);
break;
case 2:
card.setBackgroundColorResourceId(R.color.demo_card_background_color3);
break;
case 3:
card.setBackgroundColorResourceId(R.color.demo_card_background_color2);
break;
case 4:
card.setBackgroundColorResourceId(R.color.demo_card_background_color1);
break;
}
cards.add(card);
}
CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_colors);
if (listView != null) {
listView.setAdapter(mCardArrayAdapter);
}
}
use of it.gmariotti.cardslib.demo.cards.ColorCard in project cardslib by gabrielemariotti.
the class ChangeValueCardFragment method initCards.
/**
* Inits the initial card
*/
private void initCards() {
card1 = new CardExample(getActivity(), "Header", "Title");
cardView1 = (CardView) getActivity().findViewById(R.id.carddemo_card_changevalue_id);
cardView1.setCard(card1);
card2 = new CardExample2(getActivity(), "Header", "Title");
cardView2 = (CardView) getActivity().findViewById(R.id.carddemo_card_changevalue_id2);
cardView2.setCard(card2);
card3 = new CardExample3(getActivity(), "Header", "Title");
cardView3 = (CardView) getActivity().findViewById(R.id.carddemo_card_changevalue_id3);
cardView3.setCard(card3);
card4 = new ColorCard(getActivity());
card4.setTitle("A simple car");
cardView4 = (CardView) getActivity().findViewById(R.id.carddemo_card_changevalue_id4);
StateListDrawable initDrawable = new StateListDrawable();
initDrawable.addState(new int[] { android.R.attr.state_pressed }, getResources().getDrawable(R.drawable.pressed_background_card));
initDrawable.addState(new int[] {}, getResources().getDrawable(R.drawable.demo_card_background_color1));
card4.setBackgroundResource(initDrawable);
cardView4.setCard(card4);
}
Aggregations