How to pass int array of color resource ids from array.xml to SwipeRefreshLayout.setColorSchemeResources

岁酱吖の 提交于 2019-12-04 03:23:59
Andrew Cross

Turns out I was missing two key pieces.

Wrong Code:

swipeRefreshLayout.setColorSchemeResources(R.array.swipeRefreshColors);

Correct Code:

swipeRefreshLayout.setColorSchemeColors(getResources().getIntArray(R.array.swipeRefreshColors));

There were two things I was missing.

1) I needed to indicate that I was getting an IntArray from my array.xml file. This is done through getResources().getIntArray(R.array.swipeRefreshColors).

The answer was deleted, but thanks to whoever suggested this before.

2) The key part that was wrong is that I had to use setColorSchemeColors instead of setColorSchemeResources. I guess at some point in the build process the references I had in Array were converted to explicit color values.

Hopefully this can help someone else!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!