可以在ListView不滚动的swipeRefreshLayoutListView、swipeRefreshLayout

由网友(僵尸会跳小芭蕾)分享简介:我有一个问题,SwipeRefreshLayout。我有一个列表视图中的布局中,每一次我在列表中向上滚动查看刷卡刷新布局tiggered,你永远无法回滚到布局的顶部。任何人有什么想法?I'm having an issue with the SwipeRefreshLayout. I have a list view...

我有一个问题,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));
        }
    });
阅读全文

相关推荐

最新文章