1

我开发了一个支持两种语言英语(en)和西班牙语(es)的应用程序,以支持多语言我遵循 developer.android 的链接http://developer.android.com/training/basics/supporting-devices/languages.html 我已将西班牙图像放入可绘制文件夹 drawable-es-rES-hdpi、drawable-es-rES-ldpi、drawable-es-rES-mdpi 和所有与西班牙语相关的文本到 values-es 文件夹中的 strings.xml 中。

当我从应用程序的设置中将语言从英语更改为西班牙语时,它将所有文本从英语更改为西班牙语工作正常但是应用程序没有从西班牙语可绘制文件夹中获取图像(此问题发生在 HDPI 设备和所有文本中,图像更改是在三星 Galaxy ACE(分辨率:320 X 480)等 MDPI 设备上运行良好。

我在使用 OS 4.1.2、分辨率 480 X 800 的设备 Google Nexus 上遇到了这个问题。

有人遇到过这样的问题吗?请帮我。

4

1 回答 1

2

最后我得到了解决方案。

我只用语言创建本地对象,直到姜饼它改变了英语 <-> 西班牙语的所有文本和图像,但它不会改变果冻豆上的图像:我的英语和西班牙语的旧本地对象:

区域设置 locale2 = 新区域设置(appLanguageStr)

工作本地对象

Locale locale2 = new Locale(appLanguageStr, countrycode);

这是对姜饼和果冻豆都适用的最后一种方法:

public void updateAppsLanguage(String appLanguageStr) 
{
    Locale locale2 = null;
    if(appLanguageStr.equalsIgnoreCase("English"))
    {
        appLanguageStr = "en";
        locale2 = new Locale(appLanguageStr); 
    }
    else if(appLanguageStr.equalsIgnoreCase("Spanish"))
    {
        appLanguageStr = "es";
        locale2 = new Locale(appLanguageStr, "esp"); 
    }

    Locale.setDefault(locale2);
    Configuration config2 = new Configuration();
    config2.locale = locale2;
    getBaseContext().getResources().updateConfiguration(config2, getBaseContext().getResources().getDisplayMetrics());
    //Refresh the current page 
    finish();
    Intent intent = new Intent(this,AppSetting.class);
    startActivity(intent);
}
于 2012-12-06T07:53:21.737 回答