2016/09/14

Android Studio 2.2 - How to solve the issue of "Warning: [I18N] Hardcoded string......."

When seeing warning message such as "Warning: [I18N] Hardcoded string......." it means that instead of using a string resource to hold the string, the string is hard coded into the App. Hard coding the string into the App. is not recommended because it makes it difficult for the App. to support multiple languages.





Android Studio makes it quite easy to fix this issue.

Step - 1, Click on "Extract string resource" to bring up the "Extract Resource" window.


Step - 2, Click OK. The "@string/" indicates that the string is no longer hard coded into the App., but a part of the string resource.


Below is the setting for textView2 before extracting the string resource. It's clear that the string "Tap To Play Song." is hard coded into the App.


Below is the setting for the same textView2 after extracting the string resource. It's clear that the string "Tap To Play Song." is now a part of the string resource.


No comments:

Post a Comment