找不到资源异常 SwipeRefreshLayout ProgressBackground
Resource not found Exception SwipeRefreshLayout ProgressBackground
我收到资源未找到异常
android.content.res.Resources$NotFoundException: Resource ID #0xffff0000
执行此操作时:
swipeLayout.setProgressBackgroundColor(getResources().getColor(R.color.red));
虽然我在 colors.xml 中有这个:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#FF0000</color>
</resources>
我在我的项目中使用 R(不是 android.R)
Gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "xxx"
minSdkVersion 11
targetSdkVersion 18
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.code.gson:gson:2.3'
compile 'com.mcxiaoke.volley:library:1.0.6'
compile 'com.android.support:support-v4:21.0.3'
}
有什么解决办法吗?
setProgressBackgroundColor
方法的参数应该是颜色资源ID,而不是表示颜色的整数。像这样使用它:
swipeLayout.setProgressBackgroundColor(R.color.red);
我收到资源未找到异常
android.content.res.Resources$NotFoundException: Resource ID #0xffff0000
执行此操作时:
swipeLayout.setProgressBackgroundColor(getResources().getColor(R.color.red));
虽然我在 colors.xml 中有这个:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#FF0000</color>
</resources>
我在我的项目中使用 R(不是 android.R)
Gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "xxx"
minSdkVersion 11
targetSdkVersion 18
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.code.gson:gson:2.3'
compile 'com.mcxiaoke.volley:library:1.0.6'
compile 'com.android.support:support-v4:21.0.3'
}
有什么解决办法吗?
setProgressBackgroundColor
方法的参数应该是颜色资源ID,而不是表示颜色的整数。像这样使用它:
swipeLayout.setProgressBackgroundColor(R.color.red);