java - Android SwipeRefreshLayout 刷新指示器不可见

标签 java android xml swiperefreshlayout

我在 fragment 内使用 android.support.v4.widget.SwipeRefreshLayout。滑动非常适合刷新我的数据,但我只能看到一个空白的白色圆圈作为滑动指示器。我看到的所有其他问题似乎都没有用。

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_all_assets,container,false);
    mListView = (ListView) view.findViewById(R.id.listView);
    mSwipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);
    mSwipeLayout.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);
    return view;
}

XML

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">


<ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/listView"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"/>

</android.support.v4.widget.SwipeRefreshLayout>

依赖

compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v13:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.google.zxing:android-integration:3.1.0'

如何让这个刷新指示器起作用?

最佳答案

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

你应该使用 setColorSchemeResources()相反,它接受颜色资源引用。

关于java - Android SwipeRefreshLayout 刷新指示器不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26640644/

相关文章:

java - 如何使用按钮作为 double 据类型将JTextField输入存储为变量?

android - 可以转换或流式传输 (Android-Chromecast) 本地文件吗?

xml - 使用 XMLlint 对空 XML 标签进行无效格式化

java - Java 在 if/else 语句中返回多个值

java - JSESSIONID 出现在 URL 中后,我的 Web 应用程序停止工作

android - VideoView内的YouTube RTSP URL播放-低质量

Android 连接检测在 Android Studio 2.2.1 中不起作用。出了什么问题?

python - Pandas read_xml 将 "N/A"读取为 NaN

java - Eclipse RCP Plugin.xml 选择计数超过 1 的命令绑定(bind)启用

java - 我收到以下代码的 SQL 语法错误和许多异常