getColor(Int Id)在Android6.0 Marshmlow上被廢棄(API 23)這個(gè)Resources.getColor(int id)方法已被廢棄。@ColorInt@Deprecatedpublic int getColor(@ColorRes int id) throws NotFoundException {
return getColor(id, null);}我該怎么辦?
3 回答

翻過(guò)高山走不出你
TA貢獻(xiàn)1875條經(jīng)驗(yàn) 獲得超3個(gè)贊
public static int getColorWrapper(Context context, int id) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return context.getColor(id); } else { //noinspection deprecation return context.getResources().getColor(id); }}
getColor
- 3 回答
- 0 關(guān)注
- 711 瀏覽
添加回答
舉報(bào)
0/150
提交
取消