use of com.nhaarman.listviewanimations.itemmanipulation.swipedismiss.undo.SimpleSwipeUndoAdapter in project ListViewAnimations by nhaarman.
the class DynamicListViewActivity method onCreate.
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dynamiclistview);
DynamicListView listView = (DynamicListView) findViewById(R.id.activity_dynamiclistview_listview);
listView.addHeaderView(LayoutInflater.from(this).inflate(R.layout.activity_dynamiclistview_header, listView, false));
/* Setup the adapter */
ArrayAdapter<String> adapter = new MyListAdapter(this);
SimpleSwipeUndoAdapter simpleSwipeUndoAdapter = new SimpleSwipeUndoAdapter(adapter, this, new MyOnDismissCallback(adapter));
AlphaInAnimationAdapter animAdapter = new AlphaInAnimationAdapter(simpleSwipeUndoAdapter);
animAdapter.setAbsListView(listView);
assert animAdapter.getViewAnimator() != null;
animAdapter.getViewAnimator().setInitialDelayMillis(INITIAL_DELAY_MILLIS);
listView.setAdapter(animAdapter);
/* Enable drag and drop functionality */
listView.enableDragAndDrop();
listView.setDraggableManager(new TouchViewDraggableManager(R.id.list_row_draganddrop_touchview));
listView.setOnItemMovedListener(new MyOnItemMovedListener(adapter));
listView.setOnItemLongClickListener(new MyOnItemLongClickListener(listView));
/* Enable swipe to dismiss */
listView.enableSimpleSwipeUndo();
/* Add new items on item click */
listView.setOnItemClickListener(new MyOnItemClickListener(listView));
}
Aggregations