List of usage examples for android.app DatePickerDialog show
public void show()
From source file:de.kirchnerei.bicycle.battery.BatteryEditFragment.java
private void doPickBatteryDate() { final Calendar now = Calendar.getInstance(); now.setTime(item.getDate());//from w w w . j a v a 2 s. c om DatePickerDialog dlg = new DatePickerDialog(getActivity(), // TODO Define a Theme for the DatePickerDialog new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { synchronized (now) { now.set(Calendar.YEAR, year); now.set(Calendar.MONTH, monthOfYear); now.set(Calendar.DATE, dayOfMonth); updateDate(now.getTime()); } } }, now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DATE)); dlg.getDatePicker().setMaxDate(System.currentTimeMillis()); dlg.getDatePicker().setFirstDayOfWeek(Calendar.MONDAY); dlg.show(); }
From source file:com.cachirulop.moneybox.activity.MovementDetailActivity.java
/** * Handler for the change get date button * /*from ww w.j ava2s. c om*/ * @param v * view that launch the event */ public void onChangeGetDateClick(View v) { Calendar cal; DatePickerDialog dlg; DatePickerDialog.OnDateSetListener ld; cal = Calendar.getInstance(); ld = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int month, int day) { onGetDateSet(view, year, month, day); } }; cal.setTime(_movement.getGetDate()); dlg = new DatePickerDialog(this, ld, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)); dlg.show(); }
From source file:com.cachirulop.moneybox.activity.MovementDetailActivity.java
/** * Handler for the change insert date button * //from www . j a v a 2 s.com * @param v * view that launch the event */ public void onChangeInsertDateClick(View v) { Calendar cal; DatePickerDialog dlg; DatePickerDialog.OnDateSetListener ld; cal = Calendar.getInstance(); ld = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int month, int day) { onInsertDateSet(view, year, month, day); } }; cal.setTime(_movement.getInsertDate()); dlg = new DatePickerDialog(this, ld, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)); dlg.show(); }
From source file:com.flowzr.activity.DateFilterActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.date_filter); df = DateUtils.getShortDateFormat(this); Intent intent = getIntent();// w w w . j a v a 2 s. com setCorrectPeriods(intent); createPeriodsSpinner(); Button bNoFilter = (Button) findViewById(R.id.bNoFilter); bNoFilter.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setResult(RESULT_FIRST_USER); finish(); } }); if (intent == null) { reset(); } else { WhereFilter filter = WhereFilter.fromIntent(intent); DateTimeCriteria c = (DateTimeCriteria) filter.get(BlotterFilter.DATETIME); if (c != null) { if (c.getPeriod() == null || c.getPeriod().type == PeriodType.CUSTOM) { selectPeriod(c.getLongValue1(), c.getLongValue2()); } else { selectPeriod(c.getPeriod()); } } if (intent.getBooleanExtra(EXTRA_FILTER_DONT_SHOW_NO_FILTER, false)) { bNoFilter.setVisibility(View.GONE); } } buttonPeriodFrom = (Button) findViewById(R.id.bPeriodFrom); buttonPeriodFrom.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Calendar c = cFrom; DatePickerDialog d = new DatePickerDialog(DateFilterActivity.this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, monthOfYear); c.set(Calendar.DAY_OF_MONTH, dayOfMonth); DateUtils.startOfDay(c); cFrom.setTimeInMillis(c.getTimeInMillis()); updateDate(); } }, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)); d.show(); } }); buttonPeriodTo = (Button) findViewById(R.id.bPeriodTo); buttonPeriodTo.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Calendar c = cTo; DatePickerDialog d = new DatePickerDialog(DateFilterActivity.this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, monthOfYear); c.set(Calendar.DAY_OF_MONTH, dayOfMonth); DateUtils.startOfDay(c); cTo.setTimeInMillis(c.getTimeInMillis()); updateDate(); } }, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)); d.show(); } }); }
From source file:com.flowzr.budget.holo.activity.RecurActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Setup ActionBar getSupportActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.recur);/*from w w w .j a va 2 s.c o m*/ df = DateUtils.getLongDateFormat(this); stopsOnDate.add(Calendar.YEAR, 1); sInterval = (Spinner) findViewById(R.id.intervalSpinner); sPeriod = (Spinner) findViewById(R.id.recurSpinner); layoutInterval = (LinearLayout) findViewById(R.id.layoutInterval); layoutRecur = (LinearLayout) findViewById(R.id.recurInterval); bStartDate = (Button) findViewById(R.id.bStartDate); bStartDate.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { final Calendar c = startDate; DatePickerDialog d = new DatePickerDialog(RecurActivity.this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, monthOfYear); c.set(Calendar.DAY_OF_MONTH, dayOfMonth); DateUtils.startOfDay(c); editStartDate(c.getTimeInMillis()); } }, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)); d.show(); } }); addSpinnerItems(sInterval, new RecurInterval[] { RecurInterval.NO_RECUR, RecurInterval.WEEKLY, RecurInterval.MONTHLY }); addSpinnerItems(sPeriod, periods); LayoutInflater inflater = getLayoutInflater(); //addLayouts(inflater, layoutInterval, intervals); addLayouts(inflater, layoutRecur, periods); Recur recur = RecurUtils.createDefaultRecur(); Intent intent = getIntent(); if (intent != null) { String extra = intent.getStringExtra(EXTRA_RECUR); if (extra != null) { recur = RecurUtils.createFromExtraString(extra); } } editRecur(recur); sInterval.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { RecurInterval interval = getRecurInterval(sInterval.getSelectedItem()); selectInterval(interval); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); sPeriod.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { RecurPeriod period = periods[position]; selectPeriod(period); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); }
From source file:com.whatsoft.contactbook.activity.ProfileActivity.java
@OnClick(R.id.edt_birthday) void onClickBirthday() { birthday = edtDOB.getText().toString(); Calendar calendar = Calendar.getInstance(); DatePickerDialog datePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() { @Override//from w w w . ja v a 2 s. c om public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { edtDOB.setError(null); edtDOB.setText(String.format(Locale.ENGLISH, "%d/%d/%d", dayOfMonth, monthOfYear, year)); } }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); datePickerDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { edtDOB.setText(birthday); } }); datePickerDialog.show(); }
From source file:com.flowzr.activity.RecurActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Setup ActionBar getSupportActionBar().setDisplayHomeAsUpEnabled(true); //@see: http://stackoverflow.com/questions/16539251/get-rid-of-blue-line, //only way found to remove on various devices 2.3x, 3.0, ... getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#000000"))); setContentView(R.layout.recur);/* www .j av a 2 s. co m*/ df = DateUtils.getLongDateFormat(this); stopsOnDate.add(Calendar.YEAR, 1); sInterval = (Spinner) findViewById(R.id.intervalSpinner); sPeriod = (Spinner) findViewById(R.id.recurSpinner); layoutInterval = (LinearLayout) findViewById(R.id.layoutInterval); layoutRecur = (LinearLayout) findViewById(R.id.recurInterval); bStartDate = (Button) findViewById(R.id.bStartDate); bStartDate.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { final Calendar c = startDate; DatePickerDialog d = new DatePickerDialog(RecurActivity.this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, monthOfYear); c.set(Calendar.DAY_OF_MONTH, dayOfMonth); DateUtils.startOfDay(c); editStartDate(c.getTimeInMillis()); } }, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)); d.show(); } }); addSpinnerItems(sInterval, new RecurInterval[] { RecurInterval.NO_RECUR, RecurInterval.WEEKLY, RecurInterval.MONTHLY }); addSpinnerItems(sPeriod, periods); LayoutInflater inflater = getLayoutInflater(); //addLayouts(inflater, layoutInterval, intervals); addLayouts(inflater, layoutRecur, periods); Recur recur = RecurUtils.createDefaultRecur(); Intent intent = getIntent(); if (intent != null) { String extra = intent.getStringExtra(EXTRA_RECUR); if (extra != null) { recur = RecurUtils.createFromExtraString(extra); } } editRecur(recur); sInterval.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { RecurInterval interval = getRecurInterval(sInterval.getSelectedItem()); selectInterval(interval); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); sPeriod.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { RecurPeriod period = periods[position]; selectPeriod(period); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); }
From source file:cz.tsystems.portablecheckin.MainActivity.java
private void getEmiseDatePicker() { Calendar c = Calendar.getInstance(); String strDate = txtEmiseDate.getText().toString(); if (strDate.length() > 0) { String parts[] = strDate.split("[.]"); if (parts.length >= 2) { c.set(Calendar.DAY_OF_MONTH, 1); c.set(Calendar.MONTH, Integer.parseInt(parts[0])); c.set(Calendar.YEAR, Integer.parseInt(parts[1])); }/*from w ww .jav a 2s. c o m*/ } int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH) - 1; int day = 1; DatePickerDialog dialog = new DatePickerDialog(getActivity(), DialogFragment.STYLE_NO_FRAME | DialogFragment.STYLE_NORMAL, onEmiseDateChangedListener, year, month, day); findAndHideField(dialog.getDatePicker(), "mMonthPicker"); // Honeycomb(+) fields: findAndHideField(dialog.getDatePicker(), "mDaySpinner"); dialog.getDatePicker().getCalendarView().setVisibility(View.GONE); dialog.show(); }
From source file:org.egov.android.view.activity.EditProfileActivity.java
/** * Function used to choose the user dob// w w w . ja v a2s .com */ @SuppressLint("NewApi") private void _showDatePicker() { DatePickerDialog datePicker = null; Calendar c = Calendar.getInstance(); int year = 0; int month = 0; int date = 0; if (dateOfBirth.equals("")) { year = c.get(Calendar.YEAR); month = c.get(Calendar.MONTH); date = c.get(Calendar.DAY_OF_MONTH); datePicker = new DatePickerDialog(this, datepicker, year, month, date); } else { String[] birth = dateOfBirth.split("-"); year = Integer.valueOf(birth[0]); month = Integer.valueOf(birth[1]) - 1; date = Integer.valueOf(birth[2]); datePicker = new DatePickerDialog(this, datepicker, date, month, year); } if (apiLevel > 13) { datePicker.getDatePicker().setMaxDate(System.currentTimeMillis()); } datePicker.show(); }
From source file:cz.tsystems.portablecheckin.MainActivity.java
private void getSTKDatePicker() { Calendar c = Calendar.getInstance(); String strDate = txtSTKDate.getText().toString(); if (strDate.length() > 0) { String parts[] = strDate.split("[.]"); if (parts.length >= 2) { c.set(Calendar.DAY_OF_MONTH, 1); c.set(Calendar.MONTH, Integer.parseInt(parts[0])); c.set(Calendar.YEAR, Integer.parseInt(parts[1])); }/*from w w w. j a v a2 s.c o m*/ } int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH) - 1; int day = 1; DatePickerDialog dialog = new DatePickerDialog(getActivity(), DialogFragment.STYLE_NO_FRAME | DialogFragment.STYLE_NORMAL, onSTKDateChangedListener, year, month, day); // pre-Honeycomb fields: findAndHideField(dialog.getDatePicker(), "mDayPicker"); // Honeycomb(+) fields: findAndHideField(dialog.getDatePicker(), "mDaySpinner"); dialog.getDatePicker().getCalendarView().setVisibility(View.GONE); dialog.show(); }