如何在ListViewAnimations中使用TimedUndoAdapter

时间:2015-02-11 23:17:35

标签: java android xml android-layout shared-libraries

我在应用程序中使用此动画列表视图ListViewAnimations,并且所有工作正常....

`SimpleSwipeUndoAdapter swipeUndoAdapter = new SimpleSwipeUndoAdapter(myAdapter,getActivity(),
            new OnDismissCallback() {
                @Override
                public void onDismiss(@NonNull final ViewGroup listView, @NonNull final int[] reverseSortedPositions) {
                    for (int position : reverseSortedPositions) {
                        myAdapter.remove(position);
                    }
                }
            }
        );

        swipeUndoAdapter.setAbsListView(mDynamicListView);
        AlphaInAnimationAdapter animAdapter = new AlphaInAnimationAdapter(swipeUndoAdapter);
        animAdapter.setAbsListView(mDynamicListView);
        animAdapter.getViewAnimator().setInitialDelayMillis(INITIAL_DELAY_MILLIS );
        mDynamicListView.setAdapter(animAdapter);
        mDynamicListView.enableSimpleSwipeUndo();
        mDynamicListView.enableDragAndDrop();
        mDynamicListView.setOnItemLongClickListener(
            new OnItemLongClickListener() {
                @Override
                public boolean onItemLongClick(final AdapterView<?> parent, final View view,
                                               final int position, final long id) {
                    mDynamicListView.startDragging(position);
                    return true;
                }
            }
        );

但如果我尝试用TimedUndoAdapter替换SimpleSwipeUndoAdapter,我会遇到以下问题:(我需要使用TimedUndoAdapter,因为我需要在一段时间后将其擦掉)

Bound mismatch: The generic constructor TimedUndoAdapter(V, Context, OnDismissCallback) of type TimedUndoAdapter is not applicable for the arguments (ArrayAdapter<String>, Activity, new OnDismissCallback(){}). The inferred type ArrayAdapter<String> is not a valid substitute for the bounded parameter <V extends BaseAdapter & UndoAdapter>

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我认为这可能是myAdapter的声明。我遇到了同样的问题。用于声明如下:ArrayAdapter。将声明更改为我定义的Adapter类(在我的情况下,MyListAdapter扩展了ArrayAdapter并实现了UndoAdapter)为我解决了这个问题。