可以在ListView不滚动的swipeRefreshLayout [英] Can't scroll in a ListView in a swipeRefreshLayout

查看:211
本文介绍了可以在ListView不滚动的swipeRefreshLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,SwipeRefreshLayout。我有一个列表视图中的布局中,每一次我在列表中向上滚动查看刷卡刷新布局tiggered,你永远无法回滚到布局的顶部。任何人有什么想法?

I'm having an issue with the SwipeRefreshLayout. I have a list view within the layout and every time I scroll upward in the list view the swipe to refresh layout is tiggered and you can never scroll back to the top of the layout. Anyone have any ideas?

推荐答案

我发现一个回答我的问题。我手动启用swipeRefreshLayout当第一个孩子在列表视图位于列表的顶部。

I found an answer to my question. I am manually enabling the swipeRefreshLayout when the first child in the listview is at the top of the list.

    listView.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {

        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            int topRowVerticalPosition = (listView == null || listView.getChildCount() == 0) ?
                            0 : expandableListView.getChildAt(0).getTop();
            refresh.setEnabled((topRowVerticalPosition >= 0));
        }
    });

这篇关于可以在ListView不滚动的swipeRefreshLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆