Android DatePickerDialog - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android DatePickerDialog class.

This code example shows how to use the following methods:
     
    updateLabel(); 
  } 
   
  public void chooseDate(View v) {
    new DatePickerDialog(ChronoDemo.this, d,
                          dateAndTime.get(Calendar.YEAR),
                          dateAndTime.get(Calendar.MONTH),
                          dateAndTime.get(Calendar.DAY_OF_MONTH))
      .show();
  } 
   
  public void chooseTime(View v) {
    new TimePickerDialog(ChronoDemo.this, t,
                          dateAndTime.get(Calendar.HOUR_OF_DAY),
                          dateAndTime.get(Calendar.MINUTE),
                          true) 
      .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:getDatePicker, setCanceledOnTouchOutside
			dismiss();
			return super.onCreateDialog(savedInstanceState);
		} 
		else{ 
			Activity mActivity = getActivity();
			DatePickerDialog dpd = new DatePickerDialog(mActivity, mFragment,
					mFragment.year, mFragment.month, mFragment.day);
			dpd.getDatePicker().setCalendarViewShown(true);
			dpd.getDatePicker().setSpinnersShown(false);
			CalendarView cv = dpd.getDatePicker().getCalendarView();
	        cv.setShowWeekNumber(true);
	        int startOfWeek = getFirstDayOfWeek(mActivity);
	        // Utils returns Time days while CalendarView wants Calendar days 
	        if (startOfWeek == Time.SATURDAY) {
	            startOfWeek = Calendar.SATURDAY;
	        } else if (startOfWeek == Time.SUNDAY) {
	            startOfWeek = Calendar.SUNDAY;
	        } else { 
	            startOfWeek = Calendar.MONDAY;
	        } 

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:setIcon, setMessage, setTitle, setCancelable, show
			tvResult.setText(""); 
 
			Calendar now = Calendar.getInstance(); 
 
			DatePickerDialog datePicDlg =  
					new DatePickerDialog(Ch09DateTimeDialog.this, 
					dsListener,	now.get(Calendar.YEAR), 
					now.get(Calendar.MONTH),  
					now.get(Calendar.DAY_OF_MONTH)); 
			datePicDlg.setTitle("輸入日期"); 
			datePicDlg.setMessage("請輸入日期"); 
			datePicDlg.setIcon(android.R.drawable.ic_dialog_info); 
			datePicDlg.setCancelable(false); 
			datePicDlg.show(); 
		} 
	}; 
	 
    private OnDateSetListener dsListener = new OnDateSetListener() {    
		public void onDateSet (DatePicker view, int year,  
				               int monthOfYear, int dayOfMonth) { 
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:setButton
        final Calendar c = Calendar.getInstance();
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);
 
        final DatePickerDialog picker = new DatePickerDialog(getActivity(), getConstructorListener(), year, month, day);
 
        if (AndroidVersion.isJBOrAbove()) 
        { 
            picker.setButton(DialogInterface.BUTTON_POSITIVE, getActivity().getString(android.R.string.ok),
                    new DialogInterface.OnClickListener()
                    { 
                        @Override 
                        public void onClick(DialogInterface dialog, int which)
                        { 
                            DatePicker dp = picker.getDatePicker();
                            mListener.onDateSet(dp, dp.getYear(), dp.getMonth(), dp.getDayOfMonth());
                        } 
                    }); 
            picker.setButton(DialogInterface.BUTTON_NEGATIVE, getActivity().getString(android.R.string.cancel),

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:
        switch (id) {
            case TIME_DIALOG_ID:
                return new TimePickerDialog(this,
                        mTimeSetListener, mHour, mMinute, false);
            case DATE_DIALOG_ID:
                return new DatePickerDialog(this,
                            mDateSetListener,
                            mYear, mMonth, mDay);
        } 
        return null; 
    } 
 
    @Override 
    protected void onPrepareDialog(int id, Dialog dialog) {
        switch (id) {
            case TIME_DIALOG_ID:
                ((TimePickerDialog) dialog).updateTime(mHour, mMinute);
                break; 
            case DATE_DIALOG_ID:
                ((DatePickerDialog) dialog).updateDate(mYear, mMonth, mDay);
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:
    this.listener = listener;
  } 
 
  @Override 
    public Dialog onCreateDialog(Bundle savedInstanceState) {
      return new DatePickerDialog(getActivity(), this.listener, this.year, this.month, this.day);
    } 
} 
 
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:setTitle, setCancelable, setCanceledOnTouchOutside
		 dia = args.getInt("dia");
	} 
 
	 @Override 
	 public Dialog onCreateDialog(Bundle savedInstanceState) {
		 DatePickerDialog d = new DatePickerDialog(getActivity(), ondateSet, anio, mes, dia);
		 d.setTitle("Seleccione Fecha");
		 d.setCancelable(true);
		 d.setCanceledOnTouchOutside(true);
		 return d;
	 } 
}  
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:show
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);
 
        // DatePickerDialogを生成 
        DatePickerDialog dialog = new DatePickerDialog(this, new OnDateSetListener() {
            @Override 
            public void onDateSet(DatePicker view, int year, int month, int day) {
                // 日付が選択された時に呼び出される 
                String text = String.format("%d-%d-%d", year, month + 1, day);
                showToast(text);
            } 
        }, year, month, day);
        // ダイアログを表示 
        dialog.show();
    } 
 
    private void showNotSupportMessage() { 
        showToast("calendarViewShown, spinnersShownは、API level 11(Android 3.0)からのみ使えます。"); 
    } 
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:setButton, setCancelable, setCanceledOnTouchOutside
        // WORKAROUND Bug in JB prevents this standard way of working since the cancel/dismiss behaviour 
        // is broken, using workaround with custom buttons and handlers for accepting date. For more information 
        // see Bug 2 in header. 
        // return new DatePickerDialog(getActivity(), callBack, year, month, day); 
 
        DatePickerDialog picker = new DatePickerDialog(getActivity(), null, // instead of a listener we implement our
                                                                            // own buttons due to the bug 
                year, month, day);
        picker.setCancelable(true);
        picker.setCanceledOnTouchOutside(true);
        picker.setButton(DialogInterface.BUTTON_POSITIVE, getString(android.R.string.ok), acceptDateListener);
        picker.setButton(DialogInterface.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener()
        { 
            @Override 
            public void onClick(DialogInterface dialog, int which)
            { /* do nothing */ 
            } 
        }); 
        return picker;
    } 
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:
		if (v == timeButton)
			new TimePickerDialog(activity, this, date.getHours(),
					date.getMinutes(), Preferences.is24HourFormat(activity))
					.show();
		else 
			new DatePickerDialog(activity, this, 1900 + date.getYear(),
					date.getMonth(), date.getDate()).show();
	} 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Android DatePickerDialog Questions & Answers:

Other Android DatePickerDialog Examples

11:	
12:	        // Create a new instance of DatePickerDialog and return it
13:	        return new DatePickerDialog(getActivity(), this, year, month, day);
14:	    }
15:

Read More

See Code Examples for Android DatePickerDialog Methods: