且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何禁用已弃用Android功能的特定Lint警告?

更新时间:2022-10-18 07:39:35

Just something new: Not sure about Android Studio, but, to remove this warning from this line, you can use:

//noinspection deprecation

This removes the warning from the next line. E.g:

//noinspection deprecation
e.setBackgroundDrawable(editTextDrawable);

It won't show an error. However, as @JJD said, this still outputs the warning to the console. But at least you can have a nice error-less code which can be useful like for Git for example. And, this prevents the problem with @SupressWarnings, which is it ignores all warnings in the method. So if you have something deprecated that you are not aware of, @SupressWarnings will hide it and you will not be warned. That is the advantage of the //noinspection