我需要在android.widget.datepicker中自定义月份名称
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了我需要在android.widget.datepicker中自定义月份名称相关的知识,希望对你有一定的参考价值。
这是我的代码。我想将日历转换为波斯日历,我需要更改月份名称
PersianCalendar persianCalendar = new PersianCalendar();
DatePicker calObj = new DatePicker(FrContext);
DateTime minDate = new DateTime(1300, 1, 1, 0, 0, 0);
minDate = DateTime.SpecifyKind(minDate, DateTimeKind.Utc);
DateTimeOffset min_Date = minDate;
DateTime maxDate = new DateTime(1500, 1, 1, 0, 0, 0);
maxDate = DateTime.SpecifyKind(maxDate, DateTimeKind.Utc);
DateTimeOffset max_Date = maxDate;
calObj.MinDate = min_Date.ToUnixTimeMilliseconds();
calObj.MaxDate = max_Date.ToUnixTimeMilliseconds();
calObj.DateTime = new DateTime(persianCalendar.GetYear(DateTime.Now),
persianCalendar.GetMonth(DateTime.Now),
persianCalendar.GetDayOfMonth(DateTime.Now),
0,0,0,
persianCalendar.GetEra(DateTime.Now));
AlertDialog.Builder aaa = new AlertDialog.Builder(FrContext);
aaa.SetView(calObj);
aaa.Show();
我使用下面的代码设置文化月份名称。但不行
public override void OnCreate(Bundle savedInstanceState)
{
var clture = CultureInfo.CreateSpecificCulture("fa-IR");
clture.DateTimeFormat = new DateTimeFormatInfo()
{
MonthNames = new string[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" },
MonthGenitiveNames = new string[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" }
};
CultureInfo.DefaultThreadCurrentCulture = clture;
Thread.CurrentThread.CurrentCulture = clture;
Thread.CurrentThread.CurrentUICulture = clture;
base.OnCreate(savedInstanceState);
// Create your fragment here
}
答案
我想将日历转换为波斯日历,我需要更改月份名称
Xamarin.Forums
的回答:Another calendar type for datepicker。
正如MohammadRezaMoradi所说,你可以下载PersianMaterialDateTimePicker并转换为dll与vs.
例如:将PersianMaterialDateTimePicker
dll添加到您的项目中。然后像这样使用波斯语Datepicker
:
Com.Mohamadamin.Persianmaterialdatetimepicker.Date.DatePickerDialog d = new Com.Mohamadamin.Persianmaterialdatetimepicker.Date.DatePickerDialog();
d.Show(FragmentManager, "test");
以上是关于我需要在android.widget.datepicker中自定义月份名称的主要内容,如果未能解决你的问题,请参考以下文章
在 cudaStreamSynchronize 之前我需要 cudaSetDevice 吗?