code: public void setBackgroundColorRes(int colorRes) {
          ColorStateList colorStateList = UiCompat.getColorStateList(getResources(), colorRes);
          if (colorStateList == null)
              setBackgroundColor(0);
          else
              setBackgroundColor(colorStateList.getDefaultColor());
      }
docs: Set the background color by resource id
  
  @param colorRes Color resource id