我有一个始终启用和ListView
实施。当我向下滑动列表时,它会刷新列表。我的问题是。如果列表的第一个项目可见或在其初始顶部显示,则如果向下滚动,则不会产生向下滚动的效果。无论如何/解决方案,如果我按下,那么它不应该做刷新效果,而是应该向下滚动,因为它是自然行为。fastScroll
SwipeRefresh
fastScroll
fastScrollThumb
Swipe
fastScrollThumb
Swipe
编辑
我XML Layout
的如下:
<?xml version="1.0" encoding="utf-8"?>
<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"
android:background="@color/white" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/buttons_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp">
<ImageView
android:id="@+id/SubmitButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/neoo_tab_selector" />
</RelativeLayout>
<ListView
android:id="@id/android:list"
style="@style/NeeoContactListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/buttons_layout"
android:layout_marginTop="10dp" />
</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
我Logic for onScroll
的启用/禁用SwipeRefresh
是:
getListView().setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
boolean enable = false;
if(getListView() != null && getListView().getChildCount() > 0){
// check if the first item of the list is visible
boolean firstItemVisible = getListView().getFirstVisiblePosition() == 0;
// check if the top of the first item is visible
boolean topOfFirstItemVisible = getListView().getChildAt(0).getTop() == 0;
// enabling or disabling the refresh layout
enable = firstItemVisible && topOfFirstItemVisible;
}
if(enable){
enableSwipe();
}else{
disableSwipe();
}
}
});