• Android未本地化应用开发教程

    在本教程之前章节的实例中均未涉及本地化的问题,在此我们先看一下未本地化的应用程序在更改了手机的区域设置后运行效果会有什么不同。首先将手机区域设置为“zh_CN”。

    新建一个 Eclipse Android Project,名为“L10NDemo”,全部使用默认设置,不修改任何代码。创建完成后,在 main.xml 文件中添加如下代码:

    <?xml version= "l.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">
    
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:text="@string/text_a" />
    
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:text="@string/text_b" />
    
        <Button
            android:id="@+id/flag_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />
    </LinearLayout>

    Main.xml 采用 LinearLayout 布局,分别放置了两个 TextView 和一个 Button,如图 1 所示。

    默认设置的运行效果
    图 1  默认设置的运行效果

更多...

加载中...