use of it.gmariotti.cardslib.library.extra.dragdroplist.internal.CardDragDropArrayAdapter in project cardslib by gabrielemariotti.
the class NativeDragDropListFragment method initCard.
/**
* This method builds a simple list of cards
*/
private void initCard() {
//Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 25; i++) {
PicassoCard card = new PicassoCard(this.getActivity());
card.setTitle("A simple card loaded with Picasso " + i);
card.setSecondaryTitle("Simple text..." + i);
card.setCount(i);
//Card must have a stable Id.
card.setId("a" + i);
card.setSwipeable(true);
cards.add(card);
}
//Set the adapter
mCardArrayAdapter = new CardDragDropArrayAdapter(getActivity(), cards);
mListView = (CardListDragDropView) getActivity().findViewById(R.id.carddemo_extra_list_dragdrop);
if (mListView != null) {
mListView.setAdapter(mCardArrayAdapter);
}
//Listener
mListView.setOnItemMovedListener(new OnItemMovedListener() {
@Override
public void onItemMoved(int originalPosition, int newPosition) {
Card card = mCardArrayAdapter.getItem(newPosition);
Toast.makeText(getActivity(), "Card " + card.getId() + " moved to position " + newPosition, Toast.LENGTH_SHORT).show();
}
});
}
use of it.gmariotti.cardslib.library.extra.dragdroplist.internal.CardDragDropArrayAdapter in project cardslib by gabrielemariotti.
the class DragDropListFragment method initCard.
/**
* This method builds a simple list of cards
*/
private void initCard() {
//Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 25; i++) {
PicassoCard card = new PicassoCard(this.getActivity());
card.setTitle("A simple card loaded with Picasso " + i);
card.setSecondaryTitle("Simple text..." + i);
card.setCount(i);
//Card must have a stable Id.
card.setId("a" + i);
card.setSwipeable(true);
cards.add(card);
}
//Set the adapter
mCardArrayAdapter = new CardDragDropArrayAdapter(getActivity(), cards);
mListView = (CardListDragDropView) getActivity().findViewById(R.id.carddemo_extra_list_dragdrop);
if (mListView != null) {
mListView.setAdapter(mCardArrayAdapter);
}
//Listener
mListView.setOnItemMovedListener(new OnItemMovedListener() {
@Override
public void onItemMoved(int originalPosition, int newPosition) {
Card card = mCardArrayAdapter.getItem(newPosition);
Toast.makeText(getActivity(), "Card " + card.getId() + " moved to position " + newPosition, Toast.LENGTH_SHORT).show();
}
});
}
Aggregations