getColor(int id) deprecated on Android 6.0 Marshmallow (API 23)

前端 未结 11 1985
我寻月下人不归
我寻月下人不归 2020-11-22 12:29

The Resources.getColor(int id) method has been deprecated.

@ColorInt
@Deprecated
public int getColor(@ColorRes int id) throws NotFoundException          


        
11条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 13:10

    In Android Marshmallow many methods are deprecated.

    For example, to get color use

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

    Also to get drawable use

    ContextCompat.getDrawable(context, R.drawable.drawble_name);
    

提交回复
热议问题