AndroidgetResources().getDrawable()被棄用的API 22使用新的AndroidAPI 22getResources().getDrawable()現(xiàn)在不受歡迎了。現(xiàn)在最好的方法是只使用getDrawable().什么改變了?
3 回答

牛魔王的故事
TA貢獻1830條經(jīng)驗 獲得超3個贊
見 我的博客 想要更完整的解釋
ContextCompat.getDrawable(context, R.drawable.***)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { return resources.getDrawable(id, context.getTheme());} else { return resources.getDrawable(id);}
getDrawable(int, Theme)
getDrawable(int)
getDrawable(int)
getDrawable(int, null)
.

素胚勾勒不出你
TA貢獻1827條經(jīng)驗 獲得超9個贊
getResources().getDrawable(R.drawable.your_drawable)
ResourcesCompat.getDrawable(getResources(), R.drawable.your_drawable, null)
ResourcesCompat
ContextCompat.getDrawable(this, R.drawable.your_drawable)
this
- 3 回答
- 0 關注
- 1457 瀏覽
添加回答
舉報
0/150
提交
取消