首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EnhancedListView SwipeRefreshLayout

EnhancedListView SwipeRefreshLayout
EN

Stack Overflow用户
提问于 2014-07-28 13:41:24
回答 1查看 795关注 0票数 0

我使用一个SwipeRefreshLayout和一个EnhancedListView来组合它们,就像GMAIL一样。当我开始横向滑动时,我仍然能够垂直滑动。在这种情况下,来自EnhancedListView的动画卡住了,如果我不完成垂直(SwipeRefreshLayout)的滑动,直到结束才会重新设置或滑动。

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

我想过的可能的解决方案:检查水平滚动和禁用SwipeRefreshLayout (swipeL.setEnabled)(False);完成swipeL.setEnabled(true);但我找不到禁用和启用它的地方。

我的布局:

代码语言:javascript
复制
<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>

我的守则:

代码语言:javascript
复制
    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);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-08-21 13:20:42

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

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24996604

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档