com.operators.swipes
Class SwipesAdapter<T>
java.lang.Object
android.widget.BaseAdapter
com.operators.swipes.SwipesAdapter<T>
- All Implemented Interfaces:
- Adapter, ListAdapter, SpinnerAdapter
public abstract class SwipesAdapter<T>
- extends BaseAdapter
This class is a common base class for data containment, made specifically for SwipesView
.
The following is a basic implementation of SwipesAdapter
:
class BasicExampleSwipesAdapter extends SwipesAdapter<Integer>
{
ArrayList<Integer>
mInts = new ArrayList<Integer>
(Arrays.asList(new Integer[]{
1, 11, 111
}));
public BasicExampleSwipesAdapter(Context context, int resource) {
super(context, resource);
}
@Override public View getView (int position, View convertView, ViewGroup parent) {
View inflatedResource = super.getView(position, convertView, parent);
TextView card_text = (TextView) inflatedResource.findViewById(R.id.card_text);
card_text.setText(getItem(position).toString());
return inflatedResource;
}
@Override public Integer getItem(int position) { return mInts.get(position); }
@Override public void removeItem(int position) { mInts.remove(position); }
@Override public int getCount() { return mInts.size(); }
}
The BasicExampleSwipesAdapter should be passed to the SwipesView.setAdapter(SwipesAdapter)
:
SwipesView sv = new SwipesView(context);
sv.setAdapter(new BasicExampleSwipesAdapter(context, R.layout.card_item));
Constructor Summary |
SwipesAdapter(Context context,
int resource)
Constructs the Swipes Adapter in Java source code. |
Method Summary |
long |
getItemId(int position)
Overrides parent implementation of getItemId. |
View |
getView(int position,
View convertView,
ViewGroup parent)
Sets up the passed in resource (with a LayoutInflator). |
abstract void |
removeItem(int position)
Is called after a card is removed from the view hierarchy at the passed position. |
Methods inherited from class android.widget.BaseAdapter |
areAllItemsEnabled, getDropDownView, getItemViewType, getViewTypeCount, hasStableIds, isEmpty, isEnabled, notifyDataSetChanged, notifyDataSetInvalidated, registerDataSetObserver, unregisterDataSetObserver |
SwipesAdapter
public SwipesAdapter(Context context,
int resource)
- Constructs the Swipes Adapter in Java source code.
- Parameters:
context
- The activity context use for creation.resource
- The resource/layout inflated from android xml.
removeItem
public abstract void removeItem(int position)
- Is called after a card is removed from the view hierarchy at the passed position.
- Parameters:
position
- The passed position of the item to be removed.
getItemId
public long getItemId(int position)
- Overrides parent implementation of getItemId.
- Parameters:
position
- The passed position of the item to be accessed.
getView
public View getView(int position,
View convertView,
ViewGroup parent)
- Sets up the passed in resource (with a LayoutInflator).
- Parameters:
position
- The passed position of the item to be accessed.convertView
- The passed view that will be inflated, or was previously.parent
- The parent that this view will eventually be attached to, if not already.