/**
* Procedure sets the background for given view as a drawable with given resource id
*/
@SuppressWarnings("deprecation")
public static void updateBackground(Context c, View v, @DrawableRes int drawableId)
{
Drawable bg = null;
if (drawableId >= 0)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
{
bg = c.getResources().getDrawable(drawableId, c.getTheme());
}
else
{
bg = c.getResources().getDrawable(drawableId);
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
{
v.setBackground(bg);
}
else
{
v.setBackgroundDrawable(bg);
}
}
CompatUtils.java 文件源码
java
阅读 35
收藏 0
点赞 0
评论 0
项目:microMathematics
作者:
评论列表
文章目录