0

我正在使用 SwipeRefreshLayout 和 EnhancedListView 像 GMAIL-App 一样组合它们。当我开始水平滑动时,我仍然可以垂直滑动。在这种情况下,EnhancedListView 的动画会卡住,如果我没有完成垂直(SwipeRefreshLayout)滑动,则不会重置或滑动到最后。

我可以看到,首先拉动刷新然后 swipeToDismiss 不起作用。只能先滑动然后刷新。所以我想这是关于beeing一个父元素。

我想到的可能解决方案:检查水平滚动并使用 swipeL.setEnabled(false) 禁用 SwipeRefreshLayout; 当完成 swipeL.setEnabled(true); 但我找不到在哪里禁用和启用它。

我的布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<RelativeLayout
    android:id="@+id/footer"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_alignParentBottom="true"
    android:background="#0A756E"
    android:gravity="center" >

    <LinearLayout
        android:id="@+id/ll_archiv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/greenbox" >

        <TextView
            android:id="@+id/tv_archiv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingBottom="10dp"
            android:paddingTop="10dp"
            android:text="@string/archiv"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#fff" />
    </LinearLayout>
</RelativeLayout>

<android.support.v4.widget.SwipeRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipe_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <de.android.voucheroo.utils.EnhancedListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/footer"
        android:layout_alignParentTop="true"
        android:descendantFocusability="blocksDescendants" >
    </de.android.voucheroo.utils.EnhancedListView>
</android.support.v4.widget.SwipeRefreshLayout>

我的代码:

    swipeL = (SwipeRefreshLayout) getActivity().findViewById(
            R.id.swipe_container);
    ll_archiv = (LinearLayout) getActivity().findViewById(R.id.ll_archiv);
    tv_archiv = (TextView) getActivity().findViewById(R.id.tv_archiv);
    elv = (EnhancedListView) getActivity().findViewById(android.R.id.list);
    elv.setDismissCallback(new OnDismissCallback() {

        @Override
        public Undoable onDismiss(EnhancedListView listView,
                final int position) {
            try {
                final Object vouch = voucher.get(position);
                voucher.remove(position);
                adapter.notifyDataSetChanged();
                return new EnhancedListView.Undoable() {

                    @Override
                    public void undo() {
                        voucher.add(position, vouch);
                        adapter.notifyDataSetChanged();
                    }

                    // Return a string for your item
                    @Override
                    public String getTitle() {
                        return "foo";
                    }

                    // Delete item completely from your persistent storage
                    @Override
                    public void discard() {
                        [...];
                    }
                };
            } catch (Exception e) {
                Log.w("ELV_EXCEPTION", e.getMessage());
                e.getStackTrace();
                return null;
            }
        }
    });
    swipeL.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            [...]
            swipeL.setRefreshing(false);
        }
    });

    // Handler
    elv.enableSwipeToDismiss();
    elv.setSwipingLayout(R.id.ll_parent);
    elv.setUndoStyle(UndoStyle.MULTILEVEL_POPUP);
4

1 回答 1

0

现在我知道我自己的问题的答案。这不是我的代码的问题,而是 SwipeRefreshView 的问题。

有一个与我在这里发现的相同问题类似的问题:SO-Answer

于 2014-08-21T13:20:42.003 回答