我想在EEEE d,MMMM格式中自定义此显示日期,日期和月份格式。
先谢谢。
答案 0 :(得分:1)
完全符合逻辑。你可以试试这个
public static class EndDatePickerFragment extends DialogFragment
implements DatePickerDialog.OnDateSetListener {
public AdvancedSearchFragment instant;
public int dd = 0, mm, yyyy;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
if (dd == 0) {
final Calendar c = Calendar.getInstance();
yyyy = c.get(Calendar.YEAR);
mm = c.get(Calendar.MONTH);
dd = c.get(Calendar.DAY_OF_MONTH);
}
DatePickerDialog dpd = new DatePickerDialog(getActivity(), this, yyyy, mm, dd);
// Added all possible null conditions
((TextView)((LinearLayout)((LinearLayout)((LinearLayout)((DatePicker)dpd.getDatePicker()).getChildAt(0)).getChildAt(0)).getChildAt(0)).getChildAt(1)).setText("My Date");
return dpd;
}
public void onDateSet(DatePicker view, int year, int month, int day) {
// Do something with the date chosen by the user
instant.doSetEndTime(year, month + 1, day);
}
}
以下这一行将设定10月13日星期五的价值
((TextView)((LinearLayout)((LinearLayout)((LinearLayout)((DatePicker)dpd.getDatePicker()).getChildAt(0)).getChildAt(0)).getChildAt(0)).getChildAt(1)).setText("My Date");
如果您想更改2017年的格式,请使用以下
((TextView)((LinearLayout)((LinearLayout)((LinearLayout)((DatePicker)dpd.getDatePicker()).getChildAt(0)).getChildAt(0)).getChildAt(0)).getChildAt(0)).setText("My Year");
因此,您可以使用日期格式&amp ;;根据需要设置日期。
我希望这会有所帮助!