【问题标题】:setRefreshing(true) does not show indicator [duplicate]setRefreshing(true) 不显示指标[重复]
【发布时间】:2014-10-21 10:51:39
【问题描述】:

我正在使用 SwipeRefreshLayout 并且一切都很好,当 Listview 有一些孩子时。问题是:当 listView 没有 chileds 时,它在 setRefreshing(true) 调用后不显示负载指示器。如何解决?

【问题讨论】:

    标签: android


    【解决方案1】:

    它实际上确实显示了指示器...在 ActionBar 后面!

    我修复它的方法如下:

        Display display = getActivity().getWindowManager().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        int height = size.y;
        getSwipeRefreshLayout().setProgressViewOffset(false, -200, height / 9);
    

    编辑

    以上不再是正确答案。正确答案如下:

    getSwipeRefreshLayout().post(new Runnable() {
        @Override public void run() {
            getSwipeRefreshLayout().setRefreshing(true);
        }
    });
    

    【讨论】:

      【解决方案2】:

      如何解决?

      我遇到了同样的问题。我的解决方法是为ListView 提供一个空视图,将ScrollViewSwipeRefreshLayout 包裹起来。撒谎:

        <android.support.v4.widget.SwipeRefreshLayout        
             xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:tools="http://schemas.android.com/tools"
             android:layout_width="match_parent"
             android:id="@android:id/empty"
             android:layout_height="match_parent" >
      
             <ScrollView
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
                <View                    
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content" />
             </ScrollView>
         </android.support.v4.widget.SwipeRefreshLayout>
      

      【讨论】:

        猜你喜欢
        • 2015-01-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-08-01
        • 1970-01-01
        相关资源
        最近更新 更多