【问题标题】:How to change language of tablet on button click?如何在按钮单击时更改平板电脑的语言?
【发布时间】:2014-04-11 07:36:36
【问题描述】:

我使用以下代码更改我的应用程序中的语言

        if (Locale.getDefault().getLanguage().equals("en")){
        Locale locale = new Locale("en");
        Locale.setDefault(locale);
        Configuration config = new Configuration();
        config.locale = locale; 
        getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
        homeLayout.setBackgroundResource(R.drawable.accueil_en);
    }
    else {
        Locale locale = new Locale("fr");
        Locale.setDefault(locale);
        Configuration config = new Configuration();
        config.locale = locale; 
        getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
        homeLayout.setBackgroundResource(R.drawable.nouveau_home0);
    }

但是当我认为我的语言没有改变时,因为我的键盘始终使用默认语言(法语)。如何在我的应用中更改语言并确保键盘也发生变化。

请帮忙

【问题讨论】:

标签: android application-settings


【解决方案1】:

您的清单文件中有以下内容吗?

<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true"
/>

您还需要在单击按钮后致电setContentView。或拨打onCreate(null);

【讨论】:

  • 你需要调用 setContentView 或 onCreate(null)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-21
  • 1970-01-01
  • 1970-01-01
  • 2014-05-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多