Resolved color instead of a resource id

前端 未结 6 887
名媛妹妹
名媛妹妹 2020-12-14 06:02

Recently I\'ve seen appeared a lint error in my code:

Should pass resolved color instead of resource id here: getResources().getColor(R.color.maps_l

6条回答
  •  情深已故
    2020-12-14 06:14

    Since I'm still finding this on Google and it is deprecated, I thought I'd might as well share the current method of doing this.

    check getResources().getColor() is deprecated

    ContextCompat.getColor(context, R.color.color_name)
    

提交回复
热议问题