I've got Android's SwipeRefreshLayout working and am trying to customize the colors across all the pull to refreshes throughout the app. In order to follow the DRY principle, I've tried moving the desired colors to array.xml as follows:
<resources>
<array name="swipeRefreshColors">
<item>@color/pink</item>
<item>@color/green</item>
</array>
</resources>
However, when I try and import them into the swipe to refresh:
swipeRefreshLayout.setColorSchemeResources(R.array.swipeRefreshColors);
I get a Resources$NotFoundException:
android.content.res.Resources$NotFoundException: Resource ID #0x7f060001
at android.content.res.Resources.getValue(Resources.java:1233)
at android.content.res.Resources.getColor(Resources.java:887)
at android.support.v4.widget.SwipeRefreshLayout.setColorSchemeResources(SwipeRefreshLayout.java:477)
I've tried a couple things such as subclassing the SwipeRefreshLayout code and hard coding the colors there, but it's definitely a hack. There's got to be a way to reference an array of colors from the Activity to customize it.
Any help would be greatly appreciated!
*swipeRefreshColors
, if you initialise the variable elsewhere. Otherwise I guess it would just be asetColorSchemeColors(*...
:) – Osis