修改
改為
修改
改為
LANGUAGE="en_US:en"
修改
改為
修改
改為
Environment:
Win2003 + Eclipse + SDK Platform Android 2.2, API 8, revision 2
語系資源檔路徑:Project/res/[values]
[values]語系目錄名對應如下:
預設:values
英文: values-en
繁體中文: values-zh-rTW
簡體中文: values-zh-rCN
日文: values-ja
美式英文: values-en-rUS
英式英文: values-en-rUK
當程式執行時會依據手機的語系設定載入對應的語系資源,
Resources res = getResources();
Configuration conf = res.getConfiguration();
conf.locale = Locale.TRADITIONAL_CHINESE;//中文
DisplayMetrics dm = res.getDisplayMetrics();
res.updateConfiguration(conf, dm);
<span class="Apple-style-span" style="color: #6aa84f;">======Code=============================</span><br>
package tw.cww.tipcalculator;<br>
<br>
<span class="Apple-style-span" style="color: blue;"> import java.util.Locale;</span><br>
<br>
import android.app.Activity;<br>
<span class="Apple-style-span" style="color: blue;"> import android.content.res.Configuration;<br>
import android.content.res.Resources;</span> import android.os.Bundle;<br>
<span class="Apple-style-span" style="color: blue;"> import android.util.DisplayMetrics;</span><br>
<br>
public class TipCalculator extends Activity {<br>
/** Called when the activity is first created. */<br>
@Override<br>
public void onCreate(Bundle savedInstanceState) {<br>
super.onCreate(savedInstanceState);<br>
<br>
<span class="Apple-style-span" style="color: blue;"> Resources res = getResources();<br>
Configuration conf = res.getConfiguration();<br>
conf.locale = Locale.TRADITIONAL_CHINESE;//中文<br>
DisplayMetrics dm = res.getDisplayMetrics();<br>
res.updateConfiguration(conf, dm);</span><br>
<br>
setContentView(R.layout.main);<br>
}<br>
}<br>
======Code End=============================
==2011/05/11==