在您的onCreate方法中調用以下語言以挑選語言環境字符串中提供的語言。
/**
* Set the default Locale for app
* @param context context on which the locale will be implemented
* @param locale new locale for example, <b>sv</b> for Swedish or <b>en</b> for English
*/
public static void setDefaultLocale(Context context, String locale) {
Locale locJa = new Locale(locale.trim());
Locale.setDefault(locJa);
Configuration config = new Configuration();
config.locale = locJa;
context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
locJa = null;
config = null;
}
謝謝你,但它沒有工作,你確定它是否正在工作?也許我做錯了什麼。 – juliadream 2012-04-13 06:54:06
是的,它的工作原理。在** setContentView ** – waqaslam 2012-04-13 06:56:14
之前調用它好吧,我會再試一次。我的結構有點不同,沒有onCreate或setContentView方法,所以我認爲我找不到調用此函數的正確位置。 – juliadream 2012-04-13 06:59:45