Set Locale programmatically

后端 未结 14 1444
Happy的楠姐
Happy的楠姐 2020-11-22 05:55

My app supports 3 (soon 4) languages. Since several locales are quite similar I\'d like to give the user the option to change locale in my application, for instance an Itali

14条回答
  •  情深已故
    2020-11-22 06:21

    Hope this help(in onResume):

    Locale locale = new Locale("ru");
    Locale.setDefault(locale);
    Configuration config = getBaseContext().getResources().getConfiguration();
    config.locale = locale;
    getBaseContext().getResources().updateConfiguration(config,
          getBaseContext().getResources().getDisplayMetrics());
    

提交回复
热议问题