I have colors in my String.xml file, as shown below:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="txtEmail">Email </string>
<string name="txtPin">Pin Code</string>
<string name="lblProtected"> Protected</string>
<color name="MiscellaneousPercent">#ffff992b</color>
<color name="MusicPercent">#ffffdd58</color>
<color name="PicturesPercent">#ff48aa71</color>
<color name="eBooksPercent">#ff00cff9</color>
<color name="DocumentsPercent">#ff019df2</color>
</resources>
I want to use the these colors in class in my projects in order to iterate through the colors, by code.
public class BreakDownBar extends View {
public BreakDownBar(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onDraw(Canvas canvas) {
for (int i = 0; i < 5; i++) {
Paint paint = new Paint();
paint.setColor(/*I want to use the colors HERE*/);
}
}
}
How can I use the colors in the onDraw method in SetColor()like above? Can I put the colors in the String.XMl file in an array?
Can any one help me?