Android---过时类或方法

获取颜色


  • Deprecated
Context.getResources().getColor(@ColorRes int id)
  • Instead
//1.设置主题
Context.getResources().getColor(@ColorRes int id, @Nullable Theme theme)
//2.Context兼容类
ContextCompat.getColor(@NonNull Context context, @ColorRes int id)

获取Drawble


  • Deprecated
Context.getResources().getDrawable(@DrawableRes int id)
  • Instead
//1.设置主题
Context.getResources().getDrawable(@DrawableRes int id, @Nullable Theme theme)
//2.Context兼容类
ContextCompat.getDrawable(@NonNull Context context, @DrawableRes int id)

fromHtml


  • Deprecated
Html.fromHtml(str)
  • Instead
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
    content= Html.fromHtml(str,Html.FROM_HTML_MODE_LEGACY);
} else {
    content= Html.fromHtml(str);
}

你可能感兴趣的:(Android---过时类或方法)