Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android pull刷新空进度(无箭头)_Java_Android_Pull To Refresh - Fatal编程技术网

Java Android pull刷新空进度(无箭头)

Java Android pull刷新空进度(无箭头),java,android,pull-to-refresh,Java,Android,Pull To Refresh,我在我的应用程序中使用谷歌的SwipeContainer,代码如下: <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/swipeContainer" android:layout_width="match_parent" android:layout_height=

我在我的应用程序中使用谷歌的SwipeContainer,代码如下:

<android.support.v4.widget.SwipeRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipeContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/policeButton"
    android:layout_marginTop="10dp">

<ListView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/listView"
    android:layout_alignParentEnd="true"
    android:layout_below="@+id/policeButton"
    android:layout_marginTop="10dp" />
</android.support.v4.widget.SwipeRefreshLayout>
在MainActivity中,我放置了以下代码:

compile 'com.android.support:support-v4:23.1.1'
private SwipeRefreshLayout swipeContainer;

protected void onCreate(Bundle savedInstanceState) {
swipeContainer = (SwipeRefreshLayout) findViewById(R.id.swipeContainer);

    swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    loadLights();
                }
            }, 2000);
        }
    });
    swipeContainer.setColorSchemeColors(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light
            );
}
拉刷新代码将更新我的列表。 但是:当刷新操作正在进行时,旋转箭头不会显示。因此,在刷新时会出现一个空圆圈,它将在
loadLights()
完成后隐藏,因为我添加了
swipeContainer.setRefreshing(false)在那里


有人知道如何显示旋转箭头吗?

问题是
setColorSchemeColors()
需要颜色整数作为输入,如
color.BLUE
,而不是颜色资源ID

因此,显示箭头代码的颜色应如下所示:

 swipeRefreshLayout.setColorSchemeColors(Color.BLACK,
            Color.BLUE,
            Color.GREEN,
            Color.GRAY

    );
 swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light
    );
用于设置颜色资源ID的代码应如下所示:

 swipeRefreshLayout.setColorSchemeColors(Color.BLACK,
            Color.BLUE,
            Color.GREEN,
            Color.GRAY

    );
 swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light
    );

Pfft。是的,你是对的。现在我有一些漂亮的旋转箭头。谢谢