EditText用西班牙语

时间:2012-09-19 15:33:58

标签: android localization translation

我有以下EditText:

EditText et1 = (EditText) findViewById(R.id.txtSp);

当用户在此EditText中输入内容时,它应该以西班牙语而不是英语显示文本。 我怎样才能做到这一点?

注意:我的应用程序的语言是英语。

2 个答案:

答案 0 :(得分:0)

您可以使用该代码在运行时更改语言环境:

 Resources res = getApplicationContext().getResources();

 Locale locale = new Locale("en"); //<--- use your locale code here
 Locale.setDefault(locale);

 Configuration config = new Configuration();
 config.locale = locale;

 res.updateConfiguration(config, res.getDisplayMetrics());

我认为您之后也需要重置布局。

答案 1 :(得分:0)

根据这篇文章,无法更改当前正在运行的应用的区域设置。

Google Groups -> Android Developers

&#34; DH&#34;理查德在这篇文章中提到的是一个Android框架工程师。查看理查德的上一篇文章,了解她的评论链接。

相关问题