我得到的資源未發現異常資源異常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)
搖籃:
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'
}
任何想法解決這一問題?
檢查是否導入了正確的R,如果是的話嘗試清理項目。 – domi 2015-02-05 22:34:42