Android SwipeRefreshLayout在设置背景时出现异常
我需要将背景色设置为swiperefreshlayout的圆形图像视图 它总是给出一个例外:Android SwipeRefreshLayout在设置背景时出现异常,android,android-5.0-lollipop,Android,Android 5.0 Lollipop,我需要将背景色设置为swiperefreshlayout的圆形图像视图 它总是给出一个例外: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mobile.clubgecko.beta/com.mobile.clubgecko.activities.ClubGeckoBaseActivity}: android.content.res.Resources$NotFoundException: Reso
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mobile.clubgecko.beta/com.mobile.clubgecko.activities.ClubGeckoBaseActivity}: android.content.res.Resources$NotFoundException: Resource ID #0xfffd6c00
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
我用过以下方法,但没有运气
swipeRefreshLayout.setProgressBackgroundColor(Color.parseColor("#fd6c00"));
swipeRefreshLayout.setProgressBackgroundColor(context.getResources().getColor(R.color.geckocolor));
请尝试
setProgressBackgroundColorSchemeColor()
,setProgressBackgroundColor()
已被弃用
旧的不推荐使用的方法需要资源id,但您正在传递颜色值。我在GrepCode上查找了
453 public void More ...setProgressBackgroundColor(int colorRes) {
454 mCircleView.setBackgroundColor(colorRes);
455 mProgress.setBackgroundColor(getResources().getColor(colorRes));
456 }
他们使用getResources().getColor()
检索颜色。如果您提供的是真实颜色,而不是资源id,则查找将失败(根据异常)。您必须提供颜色的资源id。从
swipeRefreshLayout.setProgressBackgroundColor(context.getResources().getColor(R.color.geckocolor));
到
从ClubGeckobaseActivity发布onCreate方法根据现有文档,API中没有名为setProgressBackgroundColorSchemeColor的方法。不接受代码。给出编译错误。上述解决方案对我有效
swipeRefreshLayout.setProgressBackgroundColor(R.color.geckocolor);