android - 如何在 Android Kotlin 中抑制字符串常量的拼写检查?

标签 android android-studio kotlin android-lint

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/

相关文章:

android - 当 EditText 被聚焦时我该如何 react ?

安卓工作室断言错误: Don't invoke waitForSmartMode from inside read action in dumb mode

Android.mk *** 缺少分隔符。停止。预建库的 LOCAL_SRC_FILES 应该只包含一个项目

kotlin - 为什么 Kotlin 枚举属性不是编译时常量?

kotlin - 如何使用带左方差注释的 flatMap vavr Either

android - Xamarin 颜色导致构建错误

android - 以编程方式设置工具栏高度Android

android - 错误:Execution failed for task ':app:proguardRelease' (invalid entry CRC)

android-studio - Android Studio ActivityMain.kt 未从 Activity-main.xml 中找到 TextView、按钮等的 ID

android - OpenGL ES 2 纹理图集最前沿