2011-05-31

Ubuntu Server i386 安裝完 CLI 中文顯示亂碼

修改

$sudo vi /var/lib/locales/supported.d/local

改為

en_US.UTF-8 UTF-8


修改

$sudo /etc/default/locale

改為

LANG="en_US.UTF-8"
LANGUAGE="en_US:en"

2011-05-11

Android 多國語系

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

當程式執行時會依據手機的語系設定載入對應的語系資源,

測試的時候可在 onCreate() 中加入以下程式碼測試不同的語系執行結果

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==

adsense