多语言应用中的图片获取问题

时间:2012-11-22 13:31:03

标签: android multilingual screen-resolution android-4.2-jelly-bean hdpi

我开发了一款支持两种语言的应用程序English(en)&西班牙语(es),支持多语言我跟着developer.android的链接http://developer.android.com/training/basics/supporting-devices/languages.html 我把西班牙图像放在drawable文件夹drawable-es-rES-hdpi,drawable-es-rES-ldpi,drawable-es-rES-mdpi和所有西班牙语相关文本到values-es文件夹中的strings.xml。

当我从应用程序的设置将语言从英语更改为西班牙语时,它将所有文本从英语更改为西班牙语正在正常工作但是应用程序未从西班牙语可绘制文件夹中获取图像(此问题适用于HDPI设备& 所有文本,图像更改在MDPI设备上正常工作,如三星Galaxy ACE(Res:320 X 480))。

我在使用OS 4.1.2,分辨率为480 X 800的设备Google Nexus上遇到此问题。

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

1 个答案:

答案 0 :(得分:2)

最后我得到了解决方案。

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

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

工作本地对象

区域设置locale2 =新区域设置(appLanguageStr,国家/地区代码);

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

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);
}