Android 如何动态更改数据的语言

Android 如何动态更改数据的语言,android,Android,我有创建语言选择菜单。我通过JSON收集数据,因此这是运行时的。现在我需要更改内容或数据的语言,所以我正在使用此代码。但它不起作用 String languageToLoad = "fa"; // your language Locale locale = new Locale(languageToLoad); Locale.setDefault(locale); Configuration config = new Configuration();

我有创建语言选择菜单。我通过JSON收集数据,因此这是运行时的。现在我需要更改内容或数据的语言,所以我正在使用此代码。但它不起作用

     String languageToLoad  = "fa"; // your language
    Locale locale = new Locale(languageToLoad); 
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    getBaseContext().getResources().updateConfiguration(config, 
      getBaseContext().getResources().getDisplayMetrics());

请帮帮我。有没有其他方法可以转换成语言?或者任何库?

AFAIK..您不能更改来自webservice的数据的语言。为此,您应该有用该语言提供数据的Web服务。@Ketan请确认。我想可能还有别的办法?请check@user1629977您必须使用将运行时数据转换为相应语言的第三方库。可能对您有帮助,或者您可以参考嘿,语言代码是正确的字符串languageToLoad=“fa”;你有文件夹的值吗?如果是这样,请查看它的字符串文件。@BrijeshPatel他说的是来自JSON API的数据。那么,我们如何改变数据的语言呢?
    I think method you are using is correct. please check your language code.
    protected void language(String languageToLoad) {
            // TODO Auto-generated method stub
            Locale locale = new Locale(languageToLoad);   
            Locale.setDefault(locale); 
            Configuration config = new Configuration();  
            config.locale = locale;  
            getBaseContext().getResources().updateConfiguration(config,   
            getBaseContext().getResources().getDisplayMetrics());  
        }

   Be sure that strings file are exists in folder name appending by same language code.