java Android Studio 中支持的@SuppressWarnings 值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17603677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-01 02:26:50  来源:igfitidea点击:

Supported @SuppressWarnings Values in Android Studio

javaandroidintellij-ideaandroid-studio

提问by Murkaeus

What are all of the supported values for @SuppressWarningsin Android Studio?

@SuppressWarningsAndroid Studio 中支持的所有值是什么?

I couldn't find any documentation on it, and I know it isn't the same as Eclipse because "null" doesn't work. You can catch null warnings with "all", but as you can imagine I'd rather not.

我找不到关于它的任何文档,而且我知道它与 Eclipse 不同,因为“null”不起作用。您可以使用“all”捕获空警告,但正如您想象的那样,我宁愿不这样做。

回答by CrazyCoder

Press Alt+Enter(Windows, Linux) or Option+Enter(OS X), then either press or click on the arrow pointing right at the end of "Replace with lambda...", finally select some of the Suppress...menu items available.

Alt+ Enter(Windows、Linux)或Option+ Enter(OS X),然后按或单击“替换为 lambda...”末尾的向右箭头,最后选择一些可用的Suppress...菜单项。

enter image description here

在此处输入图片说明

回答by Sayed Abolfazl Fatemi

Look at this page for list of @SuppressWarnings:

查看此页面以获取以下列表@SuppressWarnings

https://gist.github.com/elevenetc/bf795f94aaf3e92169ef

https://gist.github.com/elevenetc/bf795f94aaf3e92169ef

回答by Tom Rutchik

I couldn't get any of the above solutions work for me, or rather what they were saying seemed not to apply to my version of Android Studio (3.4.1) running on Windows 10. Here's what I did to solve this problem of not knowing what string value to supply to @SuppressWarnings

我无法让上述任何解决方案对我有用,或者更确切地说,他们所说的似乎不适用于我在 Windows 10 上运行的 Android Studio (3.4.1) 版本。这是我为解决这个问题所做的工作知道要提供给@SuppressWarnings 的字符串值

I ran the "Analyze/Inspect Code..." for the module in question. You'll get an "Inspection Results" window. Navigate that window until you find the lint warning line that you want suppressed. Double clicking on the error message will take you to line of code that the warning message applies to. Right clicking on the error message will give you a drop-down menu, and you'll get an option to suppress the warning on a class, method or parameter basis. Select the way you want the warning message suppressed. Navigate to the code and you'll see the @SuppressWarning line that was added. You'll see the actual string parameter passed to the @SuppressWarning line.

我为相关模块运行了“分析/检查代码...”。您将看到一个“检查结果”窗口。导航该窗口,直到找到要抑制的 lint 警告行。双击错误消息将带您到警告消息适用的代码行。右键单击错误消息将为您提供一个下拉菜单,您将获得一个选项以基于类、方法或参数抑制警告。选择您希望抑制警告消息的方式。导航到代码,您将看到添加的 @SuppressWarning 行。您将看到传递给@SuppressWarning 行的实际字符串参数。

If you rerun "Analyze/Inspect Code.." again, that same warning will show up in the "Inspection Result" window, but this time you'll see that the line will also say that it's suppressed.

如果您再次运行“Analyze/Inspect Code..”,同样的警告将显示在“Inspection Result”窗口中,但这次您会看到该行还会说它被抑制了。

回答by ali sampson

This is very simple, just click on the deprecated word and press ALT + ENTER on your keyboard, click on --> Inspection 'Deprecated API usage' options. In the drop-down menu, u can select the option that matches your choice, e.g Suppress for class, Suppress for method, Suppress for statement.. Hope it helps.

这很简单,只需单击已弃用的单词并按键盘上的 ALT + ENTER,单击 --> 检查“已弃用的 API 使用”选项。在下拉菜单中,您可以选择与您的选择相匹配的选项,例如 Suppress for class、Suppress for method、Suppress for statement.. 希望对您有所帮助。