title: Create a background resource with dynamic color at runtime in android
body: <p>I am using <a href="https://github.com/roomorama/Caldroid" rel="nofollow">CaldroidFragment</a> for my application. Now I am trying to set the background color of a specific date using</p>
  
  <pre><code>CaldroidFragment.setBackgroundResourceForDate(int backgroundRes,
                                       java.util.Date date);
  </code></pre>
  
  <p>function. Now if I pass resource from xml, like R.color.blue as first parameter then it works, but I have to pass dynamic color value as background in runtime. I generate color dynamically within a range (something like interpolation). Now I am trying getResources().getColor() function to convert my color to resource.</p>
  
  <pre><code>private static final int COLOR_END = Color.parseColor("#BD4141");
  private static final int COLOR_START = Color.parseColor("#69A864");
  
  
  
  mCaldroidFragment.setBackgroundResourceForDate(
                          getResources().getColor(getInterPolateColor(2)),
                          new Date());
  
  
  private int getInterPolateColor(int value) {
              return Utility.interpolateColor(COLOR_START, COLOR_END, value / (float) 15);
  }
  
  
  
  public static int interpolateColor(final int startColor, final int endColor, final float proportion) {
              final float[] hsva = new float[3];
              final float[] hsvb = new float[3];
              Color.colorToHSV(startColor, hsva);
              Color.colorToHSV(endColor, hsvb);
              for (int i = 0; i &lt; 3; i++) {
                  hsvb[i] = interpolate(hsva[i], hsvb[i], proportion);
              }
              return Color.HSVToColor(hsvb);
  }
  
  
  
  private static float interpolate(final float a, final float b, final float proportion) {
              return (a + ((b - a) * proportion));
  }
  </code></pre>
  
  <p>But it shows following error</p>
  
  <pre><code> android.content.res.Resources$NotFoundException: Resource ID #0xff79ab60
              at android.content.res.Resources.getValue(Resources.java:1123)
              at android.content.res.Resources.getColor(Resources.java:805)
  </code></pre>
  
  <p>Now is it possible to create background resource from color value which will act like R.color.xxx, or any solution to solve my problem.</p>