在android DatePickerDialog中将语言设置为法语 [英] Set language to French in android DatePickerDialog
本文介绍了在android DatePickerDialog中将语言设置为法语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么方法可以在法语的 DatePickerDialog
中显示日期
Is there any way to have date displayed in DatePickerDialog
in french
我已经搜索过这个但没有找到结果
I have searched about this but found no results
这是我的代码:
Calendar c = Calendar.getInstance();
picker = new DatePickerDialog(PaymentView.this,
PaymentView.this,
c.get(Calendar.YEAR),
c.get(Calendar.MONTH),
c.get(Calendar.DAY_OF_MONTH));
picker.setIcon(R.drawable.ic_launcher);
picker.setTitle("Choisir la date");
picker.getDatePicker().setMinDate(System.currentTimeMillis() - 2000);
我想要法语缩写而不是 2014 年 11 月 21 日星期五我还在实例化它之前添加了:
Instead of Fri, Nov 21, 2014 I want to have french abbreviation I have also added that before instantiate it :
Locale locale = new Locale("FR");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getApplicationContext().getResources().updateConfiguration(config, null);
推荐答案
我做到了!
我在所有 DatePickerDialog 内容之前添加了这两行:
I have added these 2 lines before all the DatePickerDialog stuff:
Locale locale = getResources().getConfiguration().locale;
Locale.setDefault(locale);
然后:
Calendar c = Calendar.getInstance();
int mYear = c.get(Calendar.YEAR);
int mMonth = c.get(Calendar.MONTH);
int mDay = c.get(Calendar.DAY_OF_MONTH);
DatePickerDialog dialog = new DatePickerDialog(MainActivity.this,
this, mYear, mMonth, mDay);
dialog.getDatePicker().setMaxDate(c.getTimeInMillis());
dialog.setTitle(R.string.main_first_day_of_your_last_period);
dialog.show();
我希望它对某人有所帮助.
I hope it helps someone.
这篇关于在android DatePickerDialog中将语言设置为法语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文