问题
I know that using string literals in Android is discouraged but I do not know why. I also would like to know what possible ways can get round this problem.
回答1:
It's not necessarily a problem, just a warning. Android encourages the use of the strings resource file where possible but you certainly can hard-code strings and have it work correctly.
See this question/answers: what's wrong with hardcoded string in android xml file?
回答2:
This isn't an Android-specific issue. It is a "best practice" for programming in general. It is always a good idea to put strings and other "localizable" data into separate files (properties files, resources, etc.). This makes localization into other languages much easier.
来源:https://stackoverflow.com/questions/29501520/why-is-using-string-literals-in-android-discouraged-what-other-better-alternati