In the previous example, we overlooked an important principle, in code and layout, to use string constants directly, such as:
<button android:text= "pattern"
Android:id= "@+id/btnpattern"
Android:layout_width= "Wrap_content"
Android:textcolor= "@color/black"
Android:checked= "true"
android:layout_height= "Wrap_content" >
</Button>
We directly define the button's display as "pattern". If you want your application to support multiple devices, multiple languages, the direct use of string constants can pose a big problem for porting programs. So design application is an important principle is to as far as possible the UI related resources (such as images, text, etc.) in the form of external resources to define.
Android supports a variety of resource types, and for each resource you can define a default resource and multiple optional resources (depending on the device configuration or language type, etc.).
The default resource is defined in relation to the device configuration and language and is used when the corresponding resource is not found with the device configuration. For example, you can define the default UI layout in Res/layout, while the screen horizontal (landscape) is defined in Res/layout-land. Android automatically chooses the right resources based on the device configuration at run time.
The following illustration shows that the default resource definitions are used when there are no optional resources defined in the two different configured devices:
The following figure applies a definition to two different devices that define two resources, one is the default resource, and the other is the resource that is displayed for the horizontal screen:
When defining optional resources, Android has a certain set of naming methods for optional resources, see http://developer.android.com/guide/topics/resources/providing-resources.html
See a full set of tutorials: http://www.bianceng.cn/OS/extra/201301/35252.htm