Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to suppress lint on specific line/string in resources xml files?

On Android, I would like to suppress lint on a specific string value or specific line on a string.xml or other resources files.

<string name="suppress_lint_string">Suppress this String</string>

<string name="dont_suppress_lint_string">Don\'t Suppress this String</string>

I would like to perform specific lint suppressing on specific strings and specific parts of layouts for examples like missing translations for specific strings that doesn't really matter between languages.

like image 902
Calvin Park Avatar asked Dec 11 '22 05:12

Calvin Park


1 Answers

If you want to suppress specific rules in specific strings without suppressing the whole file, you can use annotations.

strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>    

    <!--suppress MissingTranslation -->
    <string name="suppress_lint_string">ignore my translation</string>
    ...

</resources>

You can substitute MissingTranslation with any other lint rule.

http://tools.android.com/tips/lint/suppressing-lint-warnings

like image 183
Eduard Avatar answered Dec 29 '22 00:12

Eduard