Android Lint 将此代码示例中的字符串常量识别为“dWQGSCDx”上的拼写错误。根据文档,我应该使用 @SupressLint("Typos") 来抑制它,但这并没有实现。我看到其他人建议使用 @SuppressWarnings,但这也不起作用。
/**
* Constants.kt
*/
import android.annotation.SuppressLint
@SuppressLint("Typos")
@SuppressWarnings("SpellCheckingInspection")
const val SOME_STRING_VALUE = "...dWQGSCDx..."
请注意,这是一个文件范围的全局常量,它不在类中,因此不能在包含类上放置注释。
如何在不完全禁用拼写检查且不将“拼写错误”文本添加到字典的情况下抑制对此常量定义的拼写检查?
最佳答案
在 Kotlin 中,您可以使用 @Suppress
而不是带有以下注释的 @SuppressWarnings
来抑制此警告
@Suppress("SpellCheckingInspection")
关于android - 如何在 Android Kotlin 中抑制字符串常量的拼写检查?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47748808/