DatePicker getMonth - 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 getMonth method.

This code example shows how to use the following methods:getDayOfMonth, getMonth, getYear, setMaxDate, setMinDate
     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
	} 
 
	@Override 
	protected void onDialogClosed(final boolean positiveResult) {
		if (positiveResult) {
			this.v.set(this.dp.getYear(), this.dp.getMonth(), this.dp.getDayOfMonth());
			this.cv.put(this.getKey(), this.v.getTimeInMillis());
			if (this.ul != null) {
				this.ul.onUpdateValue(this);
			} 
			if (this.dt) {
				TimePickerDialog tpd = new TimePickerDialog(this.getContext(), this,
						this.v.get(Calendar.HOUR_OF_DAY), this.v.get(Calendar.MINUTE), true);
				tpd.setTitle(this.getTitle());
				tpd.setCancelable(true);
				tpd.show();
			} 
		} 
	} 
 
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:clearFocus, getDayOfMonth, getMonth, getYear
        tryNotifyDateTimeSet(); 
    } 
 
    private void tryNotifyDateTimeSet() { 
        if (mCallBack != null) {
            mDatePicker.clearFocus();
            mCallBack.onDateTimeSet(mDatePicker, mTimePicker, mDatePicker.getYear(),
                    mDatePicker.getMonth(), mDatePicker.getDayOfMonth(),
                    mTimePicker.getCurrentHour(), mTimePicker.getCurrentMinute());
        } 
    } 
 
    @Override 
    protected void onStop() { 
        if (Build.VERSION.SDK_INT >= 16) {
            // The default behavior of dialogs changed in JellyBean and onwards. 
            // Dismissing a dialog (by pressing back for example) 
            // applies the chosen date. This code is added here so that the custom 
            // pickers behave the same as the internal DatePickerDialog. 
            tryNotifyDateTimeSet(); 
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:clearFocus, getDayOfMonth, getMonth, getYear
			this.setButton(DialogInterface.BUTTON_POSITIVE, getContext().getText(android.R.string.ok), new DialogInterface.OnClickListener()
			{ 
				@Override 
				public void onClick(DialogInterface dialog, int which)
				{ 
					picker.clearFocus(); // focus must be cleared so the value change listener is called
					callback.onDateSet(picker, picker.getYear(), picker.getMonth(), picker.getDayOfMonth());
				} 
			}); 
		} 
		catch(Exception e)
		{ 
			// reflection probably failed 
		} 
	} 
} 
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
		textView.setText( new SpannableStringBuilder( "foo" ) );
		assertEquals( "foo", androidWidgetBuilder.getValue( textView ) );
 
		// DatePicker 
 
		DatePicker datePicker = new DatePicker( null );
		Date date = new Date( 75, 4, 9 );
		androidWidgetBuilder.setValue( date, datePicker );
		assertEquals( 1975, datePicker.getYear() );
		assertEquals( 4, datePicker.getMonth() );
		assertEquals( 9, datePicker.getDayOfMonth() );
		assertEquals( 75, ( (Date) androidWidgetBuilder.getValue( datePicker ) ).getYear() );
		assertEquals( 4, ( (Date) androidWidgetBuilder.getValue( datePicker ) ).getMonth() );
		assertEquals( 9, ( (Date) androidWidgetBuilder.getValue( datePicker ) ).getDate() );
 
		// Spinner 
 
		Spinner spinner = new Spinner( null );
		List<String> lookupList = CollectionUtils.newArrayList( "foo", "bar", "baz" );
		spinner.setAdapter( new LookupArrayAdapter<String>( null, lookupList, null ) );
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:clearFocus, getDayOfMonth, getMonth, getYear
        tryNotifyDateTimeSet(); 
    } 
 
    private void tryNotifyDateTimeSet() { 
        if (mCallBack != null) {
            mDatePicker.clearFocus();
            mCallBack.onDateTimeSet(mDatePicker, mTimePicker, mDatePicker.getYear(),
                    mDatePicker.getMonth(), mDatePicker.getDayOfMonth(),
                    mTimePicker.getCurrentHour(), mTimePicker.getCurrentMinute());
        } 
    } 
 
    @Override 
    protected void onStop() { 
        if (Build.VERSION.SDK_INT >= 16) {
            tryNotifyDateTimeSet(); 
        } 
        super.onStop(); 
    } 
 
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:clearFocus, getDayOfMonth, getMonth, getYear
    } 
 
    @Override 
    public void onClick(DialogInterface dialog, int which) {
        super.onClick(dialog, which);
        mDatePicker.clearFocus();
        onDateChanged(mDatePicker, mDatePicker.getYear(), mDatePicker.getMonth(),
                mDatePicker.getDayOfMonth());
        onDialogClosed(which == DialogInterface.BUTTON1);
    } 
 
    @Override 
    protected void onDialogClosed(boolean positiveResult) {
        if (!positiveResult) {
            sharedPreferences(); 
        } 
 
        super.onDialogClosed(positiveResult);
    } 
 
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:getDayOfMonth, getMonth, getYear, setMaxDate, setMinDate
     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:clearFocus, getDayOfMonth, getMonth, getYear
   * and {@link #onDialogClosed(boolean)}. Be sure to call the super when overriding. 
   */ 
  @Override 
  public void onClick(DialogInterface dialog, int which) {
    super.onClick(dialog, which);
    datePicker.clearFocus();
    onDateChanged(datePicker, datePicker.getYear(), datePicker.getMonth(),
        datePicker.getDayOfMonth());
    onDialogClosed(which == DialogInterface.BUTTON1); // OK?
  } 
 
  /** 
   * Produces the date the user has selected for the given preference, as a 
   * calendar. 
   *  
   * @param preferences 
   *          the SharedPreferences to get the date from 
   * @param field 
   *          the name of the preference to get the date from 
   * @return a Calendar that the user has selected 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related DatePicker getMonth Questions & Answers:

getMonth Method Overview
See Code Examples for other Android DatePicker Methods: