ListViewAnimations滑动和关闭

时间:2014-08-05 17:47:09

标签: android listview

我正在使用Niek Haarman ListViewAnimations。我想在ListView上使用上下文撤消(Swipe & Dismiss)实现Google Card Now动画。

我是否可以使用上下文代码,如下面的代码段

@Override
public void onDismiss(final AbsListView listView, final int[] reverseSortedPositions) {
    for (int position : reverseSortedPositions) {
        mAdapter.remove(position);
    }
    Toast.makeText(this, "Removed positions: " + Arrays.toString(reverseSortedPositions), Toast.LENGTH_SHORT).show();
}

private void setContextualUndoAdapter() {
    ContextualUndoAdapter adapter = new ContextualUndoAdapter(mAdapter, R.layout.undo_row, R.id.undo_row_undobutton, this);
    adapter.setAbsListView(getListView());
    getListView().setAdapter(adapter);
}

在其中一个示例(GoogleCardsActivity)上?我的意思是我需要在用户从左向右交换然后卡片消失之前显示撤消按钮。

如果可以,怎么办?非常感谢。

1 个答案:

答案 0 :(得分:2)

最后,我有办法做到这一点。以下是片段代码:

        mGoogleCardsAdapter = new GoogleCardsAdapter(this);
        SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(new ContextualUndoAdapter(mGoogleCardsAdapter, R.layout.undo_row, R.id.undo_row_undobutton, this));
        swingBottomInAnimationAdapter.setInitialDelayMillis(300);
        swingBottomInAnimationAdapter.setAbsListView(listView);