You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classCardData {
// Class to hold data for single card.
}
classCardViewHolder {
// To hold views present in card.
}
Linking your POJO to Adapter is as simplest as shown below.
classMySimpleGridAdapterextendsListGridAdapter<CardData, CardViewHolder> {
publicMySimpleGridAdapter(Contextcontext, inttotalCardsInRow) {
super(context, totalCardsInRow);
}
@OverrideprotectedCard<CardViewHolder> getNewCard(intcardwidth) {
// 1.Create Card-View programmatically (can be created by XML as well.)// 2.Setting up Card view holder.returnnewCard<CardViewHolder>(view, viewHolder);
}
@OverrideprotectedvoidsetCardView(CardDataHolder<CardData> cardDataHolder,
CardViewHoldercardViewHolder) {
// Update view values using your data & viewHolder.
}
@OverrideprotectedvoidonCardClicked(CardDatacardData) {
// Callback when card gets clicked.
}
@OverrideprotectedvoidregisterChildrenViewClickEvents(
CardViewHoldercardViewHolder,
ChildViewsClickHandlerchildViewsClickHandler) {
// Register for child-view (present inside your card) clicks if required
}
@OverrideprotectedvoidonChildViewClicked(ViewclickedChildView, CardDatacardData,
inteventId) {
// Click events for registerd chilren will be posted here
}
}
Linking MySimpleGridAdapter to ListView
// Instantiating adapterfinalintMAX_CARDS = 2;
MySimpleGridAdaptergridAdapter = newMySimpleGridAdapter(getApplicationContext(), MAX_CARDS);
// Adding data to adaptergridAdapter.addItemsInGrid(dataList);
// Attaching adapter to ListView listview.setAdapter(gridAdapter);