android - 如何使用带有下拉刷新和滑动删除的Listview

标签 android listview swiperefreshlayout

我正在使用 this 在我的 bu 中使用滑动删除图书馆。并且还使用滑动来刷新,为此我正在使用 android.support.v4.widget.SwipeRefreshLayout 所以设计很好,当我向下滑动刷新时一切看起来都很好。我的列表得到刷新,内容得到更新。

下面是我的布局

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

>
<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="true">
<com.baoyz.swipemenulistview.SwipeMenuListView
    android:id="@+id/listView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:dividerHeight="5.0sp"
    android:divider="@android:color/transparent"/>

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:gravity="center">
    <TextView
        android:id="@+id/swipeRefreshLayout_emptyView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:visibility="gone"
        android:gravity="center"
        /></ScrollView>
</FrameLayout>

问题:

因为我想通过滑动删除来删除项目,为此我必须从右向左滑动以打开删除菜单,它会打开但是当我触摸它时没有任何反应。

我现在在结果上,我认为两次手势正在相互拦截。我进行了调试,我的删除项目菜单没有任何内容没有监听点击。

请帮助我卡在中间。你有什么建议可以帮助我吗?

更新一

我调试了代码,当我点击菜单中的删除按钮时,它在日志中显示我在跟踪

D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN

我认为是忽略了我的删除项目的触摸

最佳答案

这里的最佳方式 answer是在开始扫描菜单时禁用 sweipRefreshLayout 并在完成时再次启用它 作为这段代码

list.setOnSwipeListener(new SwipeMenuListView.OnSwipeListener() {
        @Override
        public void onSwipeStart(int position) {
            mySwipeRefresh.setEnabled(false);
        }

        @Override
        public void onSwipeEnd(int position) {
            mySwipeRefresh.setEnabled(true);
        }
    });

我希望它对我有用。

关于android - 如何使用带有下拉刷新和滑动删除的Listview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36451957/

相关文章:

android - 如何将此文本添加到 Android Studio 中的 xml 文件中?

android - 没有进度微调器的 SwipeRefreshLayout

java - 如何更新和增量数据库?

android - 您可以使用 Android 上的指纹传感器找到指纹类型(例如食指、中指等)吗?

android - ListView 改变行

android - android中的自定义微调器弹出列表

Android:CollapsingToolbarLayout 和 SwipeRefreshLayout 卡住

android - SwipeRefreshLayout fragment 创建时没有动画

Android,使用 parse.com 推送通知,自动启动应用程序

javascript - 如何检测winjs ListView 滚动开始?