2017-10-13 257 views

回答

0

完全符合逻辑。你可以试试这个

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

因此,取代我的日期,您可以使用日期格式&根据需要设置日期。

我希望这会有所帮助!