0

SwipeRefreshLayout と EnhancedListView を使用して、GMAIL-App のように組み合わせています。水平にスワイプし始めても、垂直にスワイプできます。この場合、EnhancedListView からのアニメーションがスタックし、垂直 (SwipeRefreshLayout) スワイプを完了しないと、最後までリセットまたはスワイプしません。

最初に引っ張って更新してから swipeToDismiss が機能しないことがわかります。最初にスワイプしてから更新するだけです。だから私はそれが親要素であることについてだと思います。

私が考えた可能な解決策:水平スクロールを確認し、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 に答える