拉动刷新不显示加载动画

时间:2015-01-14 08:25:09

标签: android listview pull-to-refresh

我在项目中使用了this pull-to-refresh library,代码如下:

<LinearLayout>

    <TextView
            android:id="@+id/textView1"
            android:layout_width="fill_parent"
            android:layout_height="40dp"
            android:background="@color/transparent"
            android:visibility="invisible" />      

       <com.markupartist.android.widget.PullToRefreshListView     
            android:id="@+id/list_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"

            android:cacheColorHint="#00000000"
            android:clipToPadding="false"
            android:divider="@null"
            android:dividerHeight="16dp"
            android:fadingEdge="none"
            android:listSelector="@android:color/transparent"
            android:scrollbarStyle="insideInset"/>
</LinearLayout>

当我看到它的例子工作正常时,它也会显示加载动画视图。

但在我的项目中,使用上面的代码,它没有显示加载动画视图。

listView.setOnRefreshListener(new OnRefreshListener() {

                @Override
                public void onRefresh() {
                    System.out.println("Pull to refresh called");
                    onRefreshClicked(); // To Refresh my list
                    listView.onRefreshComplete();
                }
            });

这有什么问题?

2 个答案:

答案 0 :(得分:1)

删除

listView.onRefreshComplete();

因为当你进行刷新时它会停止刷新加载。

答案 1 :(得分:0)

之前我没有使用过那个特定的库,但是你有什么反对在Android的支持库中使用它的吗?适合我......

import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;

<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.support.v4.widget.SwipeRefreshLayout>