DatePicker init - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for DatePicker init method.

This code example shows how to use the following methods:getDayOfMonth, getMonth, getYear, init, setMaxDate
     if (max <= min) {
         return; 
     } 
     Calendar minCal = trimToDate(min);
     Calendar maxCal = trimToDate(max);
     int currentYear = picker.getYear();
     int currentMonth = picker.getMonth();
     int currentDayOfMonth =  picker.getDayOfMonth();
     picker.updateDate(maxCal.get(Calendar.YEAR),
             maxCal.get(Calendar.MONTH),
             maxCal.get(Calendar.DAY_OF_MONTH));
     picker.setMinDate(minCal.getTimeInMillis());
     picker.updateDate(minCal.get(Calendar.YEAR),
             minCal.get(Calendar.MONTH),
             minCal.get(Calendar.DAY_OF_MONTH));
     picker.setMaxDate(maxCal.getTimeInMillis());
 
     // Restore the current date, this will keep the min/max settings 
     // previously set into account. 
     picker.updateDate(currentYear, currentMonth, currentDayOfMonth);

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getDayOfMonth, getMonth, getYear, init, setMaxDate
     if (max <= min) {
         return; 
     } 
     Calendar minCal = trimToDate(min);
     Calendar maxCal = trimToDate(max);
     int currentYear = picker.getYear();
     int currentMonth = picker.getMonth();
     int currentDayOfMonth =  picker.getDayOfMonth();
     picker.updateDate(maxCal.get(Calendar.YEAR),
             maxCal.get(Calendar.MONTH),
             maxCal.get(Calendar.DAY_OF_MONTH));
     picker.setMinDate(minCal.getTimeInMillis());
     picker.updateDate(minCal.get(Calendar.YEAR),
             minCal.get(Calendar.MONTH),
             minCal.get(Calendar.DAY_OF_MONTH));
     picker.setMaxDate(maxCal.getTimeInMillis());
 
     // Restore the current date, this will keep the min/max settings 
     // previously set into account. 
     picker.updateDate(currentYear, currentMonth, currentDayOfMonth);

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getDayOfMonth, getMonth, getYear, init
		if (isDateAfter(view)) {
			textViewVisible(); 
			Calendar mCalendar = Calendar.getInstance();
			mCalendar.setFirstDayOfWeek(Calendar.MONDAY);
			if (color) {
				view.init(mCalendar.get(Calendar.YEAR),mCalendar.get(Calendar.MONTH),mCalendar.get(Calendar.DAY_OF_MONTH), this);
				color = false;
			} else { 
				view.init(year, month, day, null);
			} 
 
		} else { 
			textViewInvisible(); 
	        updateTitle(year, month, day);
		} 
    } 
 
    private void updateTitle(int year, int month, int day) {
        mCalendar.set(Calendar.YEAR, year);
        mCalendar.set(Calendar.MONTH, month);

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:init
        super.onPrepareDialogBuilder(builder);
    } 
 
    @Override 
    protected View onCreateDialogView() {
        this.mDatePicker = new DatePicker(getContext());
        Calendar calendar = Calendar.getInstance();
        mDatePicker.init(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH), this);
        setToday(); 
        return mDatePicker;
    } 
 
    @Override 
    public void onDateChanged(DatePicker datePicker, int year, int month, int day) {
        Calendar selected = new GregorianCalendar(year, month, day);
        mPickedDate = new Date(selected.getTimeInMillis());
    } 
 
    @Override 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setFocusable, init, setEnabled
    /** 
     * Resets date to today. 
     */ 
    public void clearAnswer() { 
        final Calendar c = new GregorianCalendar();
        mDatePicker.init(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH),
                mDateListener);
    } 
 
 
    public IAnswerData getAnswer() { 
        // clear focus first so the datewidget gets the value in the text box 
        mDatePicker.clearFocus();
        Date d =
                new Date(mDatePicker.getYear() - YEARSHIFT, mDatePicker.getMonth(), mDatePicker
                        .getDayOfMonth());
        return new DateData(d);
    } 
 
 

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getDayOfMonth, getMonth, getYear, init
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:init, getClass
            if (value != null)
                txt.setText(value);
 
            return txt;
        } else if (type.equals("org.joda.time.LocalDate")||type.equals("date")) {
            DatePicker datePicker = new DatePicker(context);
            if(value!=null){
	            int year = Integer.parseInt(value.split("-")[0]);
	            int month = Integer.parseInt(value.split("-")[1])-1;
	            int date = Integer.parseInt(value.split("-")[2]);
	            datePicker.init(year, month, date, null);
            } 
            int currentapiVersion = android.os.Build.VERSION.SDK_INT;
            if (currentapiVersion >= 11) {
              try { 
                Method m = datePicker.getClass().getMethod("setCalendarViewShown", boolean.class);
                m.invoke(datePicker, false);
              } 
              catch (Exception e) {} // eat exception in our case
            } 
        	return datePicker;
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:init
This code example shows how to use the following methods:init
   *  
   * @return a DatePicker with the date set 
   */ 
  @Override 
  protected View onCreateDialogView() {
    this.datePicker = new DatePicker(getContext());
    Calendar calendar = getDate();
    datePicker.init(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
        calendar.get(Calendar.DAY_OF_MONTH), this);
    return datePicker;
  } 
 
  /** 
   * Produces the date used for the date picker. If the user has not selected a 
   * date, produces the default from the XML's android:defaultValue. If the 
   * default is not set in the XML or if the XML's default is invalid it uses 
   * the value produced by {@link #defaultCalendar()}. 
   *  
   * @return the Calendar for the date picker 
   */ 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:init, setCalendarViewShown
     * 
     * @return a DatePicker with the date set 
     */ 
    @Override 
    protected View onCreateDialogView() {
        this.datePicker = new DatePicker(getContext());
        Calendar calendar = getDate();
        datePicker.init(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH), this);
        try{ 
            datePicker.setCalendarViewShown(false);
        } catch(NoSuchMethodError e){
            //handel ics 
        } 
        return datePicker;
    } 
 
    /** 
     * Produces the date used for the date picker. If the user has not selected a 
     * date, produces the default from the XML's android:defaultValue. If the 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related DatePicker init Questions & Answers:

init Method Overview
Initialize the state.
See Code Examples for other Android DatePicker Methods: