设置语言为法语的android DatePickerDialog [英] Set language to French in android DatePickerDialog

查看:849
本文介绍了设置语言为法语的android DatePickerDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让在法国的日期显示在 DatePickerDialog

我寻觅有关这一点,但没有发现结果

下面是我的code:

 日历C = Calendar.getInstance();

 选择器=新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日期);
 。picker.getDatePicker()setMinDate(System.currentTimeMillis的() -  2000年);
 

相反周五,二零一四年十一月二十一日我想有法语缩写 我还补充说,之前实例吧:

 区域设置区域设置=新的语言环境(FR);
 Locale.setDefault(区域);
 配置配置=新配置();
 config.locale =区域;
 getApplicationContext()getResources()updateConfiguration(配置,为空)。;
 

解决方案

我成功了!

我以前所有的DatePickerDialog的东西添加了这2行:

 区域设置区域设置= getResources()getConfiguration()语言环境。;
Locale.setDefault(区域);
 

和后认为:

 日历C = Calendar.getInstance();
INT mYear = c.get(Calendar.YEAR);
INT mMonth = c.get(Calendar.MONTH);
INT MDAY = c.get(Calendar.DAY_OF_MONTH);
DatePickerDialog对话框=新DatePickerDialog(MainActivity.this,
            对此,mYear,mMonth,MDAY);
。dialog.getDatePicker()setMaxDate(c.getTimeInMillis());
dialog.setTitle(R.string.main_first_day_of_your_last_period);
dialog.show();
 

我希望这可以帮助别人。

Is there any way to have date displayed in DatePickerDialog in french

I have searched about this but found no results

Here is my code:

 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);

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);

解决方案

I made it!

I have added these 2 lines before all the DatePickerDialog stuff:

Locale locale = getResources().getConfiguration().locale;
Locale.setDefault(locale);

and after that:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆