title: How to pass color resource as parameter (Android)
body: <p>This could be the simplest thing ever but for the life of me I haven't figured it out just yet.</p>
  
  <p>I have a method that sets the background color of layout but I want to pass the color as a parameter like we do with drawable resources. eg</p>
  
  <pre><code>public void setIcon (Drawable icon){
    this.icon = context.getResources().getDrawable(icon);
  }
  
  setIcon(R.drawable.tuborg);
  </code></pre>
  
  <p>I want to be able to do something similar with <code>color (R.color.id)</code>. I've tried</p>
  
  <pre><code>public void setColor (Color color){
    layout.setBackgroundColor(context.getResources().getColor(color));
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public void setColor (Color color){
    layout.setBackgroundColor(ContextCompat.getColor(color));
  }
  </code></pre>
  
  <p>both of which are asking for int, even <code>(int color)</code> doesn't work. Plus I'm trying to avoid Color.parse().</p>
  
  <p>This is how I'm using the function</p>
  
  <pre><code>setColor(R.color.colorAccent);
  </code></pre>
  
  <p>I have an xml with various color codes. I want to be able just call this function and get the background color change.</p>