• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • android 應用程序實現語言切換

    發表于:2011-06-24來源:未知作者:娃娃點擊數: 標簽:Android
    首先創建多語言資源,參考在MainActivity的onCreate()中添加如下代碼 public void onCreate(Bundle savedInstanceState) {

     

    首先創建多語言資源,參考

    在MainActivity的onCreate()中添加如下代碼

     

     public void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);

            setContentView(R.layout.main);

     

           String languageToLoad  = "zh";

            Locale locale = new Locale(languageToLoad);

            Locale.setDefault(locale);

            Configuration config = new Configuration();

            config.locale = locale;

            getBaseContext().getResources().updateConfiguration(config, null);

     

     

        }

     

     

    AndroidManifest.xml中:

     

     

    <application android:icon="@drawable/icon" android:label="@string/app_name">

            <activity android:name=".MainActivity"

                      android:label="@string/app_name"

                     android:configChanges="locale">

                <intent-filter>

                    <action android:name="android.intent.action.MAIN" />

                    <category android:name="android.intent.category.LAUNCHER" />

                </intent-filter>

            </activity>

     

        </application>

        <supports-screens

           android:smallScreens="true"

           android:normalScreens="true"

           android:largeScreens="true"

           android:anyDensity="true"/>

     

    每一個Activity中都要加: android:configChanges="locale"。

     <supports-screens>是為了解決如下問題:

    http://adrianvintu.com/blogengine/post/Force-Locale-on-Android.aspx

     

     

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>