use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class NativeHeaderFragment method init_standard_header_without_buttons.
/**
* This method builds a standard header without buttons
*/
private void init_standard_header_without_buttons() {
//Create a Card
Card card = new Card(getActivity());
//Create a CardHeader
CardHeader header = new CardHeader(getActivity());
//Set the header title
header.setTitle(getString(R.string.demo_header_basetitle));
card.addCardHeader(header);
//Set card in the CardViewNative
CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_header_std);
cardView.setCard(card);
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class NativeHeaderFragment method init_standard_header_with_overflow_button_dynamic_menu.
/**
* This method builds a standard header with overflow button with a dynamic menu
*/
private void init_standard_header_with_overflow_button_dynamic_menu() {
//Create a Card
Card card = new Card(getActivity());
//Create a CardHeader
CardHeader header = new CardHeader(getActivity());
//Set the header title
header.setTitle(getString(R.string.demo_header_basetitle));
//Add a popup menu. This method set OverFlow button to visible
header.setPopupMenu(R.menu.popupmain, new CardHeader.OnClickCardHeaderPopupMenuListener() {
@Override
public void onMenuItemClick(BaseCard card, MenuItem item) {
Toast.makeText(getActivity(), "Click on " + item.getTitle(), Toast.LENGTH_SHORT).show();
}
});
//Add a PopupMenuPrepareListener to add dynamically a menu entry
//it is optional.
header.setPopupMenuPrepareListener(new CardHeader.OnPrepareCardHeaderPopupMenuListener() {
@Override
public boolean onPreparePopupMenu(BaseCard card, PopupMenu popupMenu) {
popupMenu.getMenu().add("Dynamic item");
return true;
}
});
card.addCardHeader(header);
//Set card in the CardViewNative
CardViewNative cardViewNative = (CardViewNative) getActivity().findViewById(R.id.carddemo_header_overflow_dynamic);
cardViewNative.setCard(card);
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class NativeHeaderFragment method init_header_buttonleft.
/**
* This method builds a header with full custom layout, with buttons on the left
*/
private void init_header_buttonleft() {
//Create a Card
Card card = new Card(getActivity());
//Create a CardHeader
CardHeader header = new CardHeader(getActivity(), R.layout.carddemo_native_buttonleft_inner_header);
//Set the header title
header.setTitle(getString(R.string.demo_header_basetitle));
header.setOtherButtonVisible(true);
header.setOtherButtonClickListener(new CardHeader.OnClickCardHeaderOtherButtonListener() {
@Override
public void onButtonItemClick(Card card, View view) {
//Example to change dinamically the button resources
if (Build.VERSION.SDK_INT >= Constants.API_L) {
card.getCardHeader().setOtherButtonDrawable(R.drawable.ic_action_add);
} else {
card.getCardHeader().setOtherButtonDrawable(R.drawable.card_menu_button_other_add);
}
card.getCardView().refreshCard(card);
}
});
card.addCardHeader(header);
//Set card in the CardViewNative
CardViewNative cardViewNative = (CardViewNative) getActivity().findViewById(R.id.carddemo_header_buttonleft);
cardViewNative.setCard(card);
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class CardExpandFragment method init_custom_card_expand_programmatic.
/**
* This method builds a card with a collpse/expand action in programmatic way
*/
private void init_custom_card_expand_programmatic() {
//Create a Card
final Card card = new Card(getActivity());
//This provides a simple (and useless) expand area
CardExpand expand = new CardExpand(getActivity());
//Set inner title in Expand Area
expand.setTitle(getString(R.string.demo_expand_customtitle3));
card.addCardExpand(expand);
ViewToClickToExpand viewToClickToExpand = ViewToClickToExpand.builder().enableForExpandAction();
card.setViewToClickToExpand(viewToClickToExpand);
TextView tx = (TextView) getActivity().findViewById(R.id.carddemo_example_card_expand6_text);
tx.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
card.doToogleExpand();
}
});
//Set card in the cardView
CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_example_card_expand6);
cardView.setCard(card);
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class CardFragment method init_custom_card_clickable.
/**
* This method builds a custom card clickable
*/
private void init_custom_card_clickable() {
//Create a Card
CustomCard card = new CustomCard(getActivity());
//Set onClick listener
card.setOnClickListener(new Card.OnCardClickListener() {
@Override
public void onClick(Card card, View view) {
Toast.makeText(getActivity(), "Clickable card", Toast.LENGTH_LONG).show();
}
});
//Set card in the cardView
CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_example_card3_clickable);
cardView.setCard(card);
}
Aggregations