After an android project is created, the default res Directory includes layout, values, drawable, and so on.
These are the default resource file directories of the program. To implement the multi-language version, we need to add the corresponding resource files for the implementation language.
First, click the Add Android XML file button to display the following interface:
Input File Name: String. XML, select the values single region, add the region in the left list to the list on the left, and enterCN, such
At this time, the above message prompts: If region is used, you need to use the language item. Like region, we add the language to the list on the right, and fill inZH, such
Click Finish. The resource file is created. Directory: Res/Values-ZH-RCN (In fact, the above operations are to generate this directory.)
The default string. XML code:
<?xml version="1.0" encoding="utf-8"?><resources><string name="hello">Hello World, Test!</string><string name="app_name">Test-Multilingual</string></resources>
Modify the string. XML in the generated Res/Values-ZH-RCN directory:
<? XML version = "1.0" encoding = "UTF-8"?> <Resources> <string name = "app_name"> test multiple languages </string> <string name = "hello"> multi-language test </string> </resources>
Because the region is set to CN, the Res/Values-ZH-RTW directory is not found during ZH-TW, and the string. xml under the default Res/values directory is loaded.
Here, we only use values as an example. You can use other resources, images, and la S.