简体   繁体   中英

how to remove fromHtml deprecated worning using Annotation

How to remove deprecated error in an android studio.

   @SuppressWarnings("deprecated")
    public void setText(){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            tv_howTo.setText(Html.fromHtml(getResources().getString(R.string.app_name), Html.FROM_HTML_MODE_COMPACT));
        } else {
            tv_howTo.setText(Html.fromHtml(getResources().getString(R.string.app_name)));
        }
    }

I tried using @SuppressWarnings("deprecated") and @TargetApi(15) but isn't working. I need to remove the deprecated warning.

See Screenshot 在此输入图像描述

Just add //noinspection deprecation before statement like this:

//noinspection deprecation
tv_howTo.setText(Html.fromHtml(getResources().getString(R.string.app_name)));

Press Alt + Enter on fromHtml and Android Studio will suggest you actions to resolve.

You can suppress warning using Annotation. Just add @SuppressWarnings("deprecation") instead of @SuppressWarnings("deprecated") , and you won't see that warning anymore.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM