您的位置:首页 > 其它

Context#getResources().getDrawable()方法过时后的替代方法

2017-04-12 23:14 363 查看



参考:Android
getResources().getDrawable() deprecated API 22

1)使用drawable资源但不为其设置theme主题

ResourcesCompat.getDrawable(getResources(), R.drawable.name, null);


2)使用默认的activity主题

ContextCompat.getDrawable(getActivity(), R.drawable.name);


3)使用自定义主题

ResourcesCompat.getDrawable(getResources(), R.drawable.name, anotherTheme);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: