android datepickerdialog

Solutions on MaxInterview for android datepickerdialog by the best coders in the world

showing results for - "android datepickerdialog"
Turner
27 Jun 2016
1
2package com.journaldev.datetimepickerdialog;
3
4import android.app.DatePickerDialog;
5import android.app.TimePickerDialog;
6import android.support.v7.app.AppCompatActivity;
7import android.os.Bundle;
8import android.view.Menu;
9import android.view.MenuItem;
10import android.view.View;
11import android.widget.Button;
12import android.widget.DatePicker;
13import android.widget.EditText;
14import android.widget.TimePicker;
15
16import java.util.Calendar;
17
18public class MainActivity extends AppCompatActivity implements
19        View.OnClickListener {
20
21    Button btnDatePicker, btnTimePicker;
22    EditText txtDate, txtTime;
23    private int mYear, mMonth, mDay, mHour, mMinute;
24
25    @Override
26    protected void onCreate(Bundle savedInstanceState) {
27        super.onCreate(savedInstanceState);
28        setContentView(R.layout.activity_main);
29
30        btnDatePicker=(Button)findViewById(R.id.btn_date);
31        btnTimePicker=(Button)findViewById(R.id.btn_time);
32        txtDate=(EditText)findViewById(R.id.in_date);
33        txtTime=(EditText)findViewById(R.id.in_time);
34
35        btnDatePicker.setOnClickListener(this);
36        btnTimePicker.setOnClickListener(this);
37
38    }
39
40    @Override
41    public void onClick(View v) {
42
43        if (v == btnDatePicker) {
44
45            // Get Current Date
46            final Calendar c = Calendar.getInstance();
47            mYear = c.get(Calendar.YEAR);
48            mMonth = c.get(Calendar.MONTH);
49            mDay = c.get(Calendar.DAY_OF_MONTH);
50
51
52            DatePickerDialog datePickerDialog = new DatePickerDialog(this,
53                    new DatePickerDialog.OnDateSetListener() {
54
55                        @Override
56                        public void onDateSet(DatePicker view, int year,
57                                              int monthOfYear, int dayOfMonth) {
58
59                            txtDate.setText(dayOfMonth + "-" + (monthOfYear + 1) + "-" + year);
60
61                        }
62                    }, mYear, mMonth, mDay);
63            datePickerDialog.show();
64        }
65        if (v == btnTimePicker) {
66
67            // Get Current Time
68            final Calendar c = Calendar.getInstance();
69            mHour = c.get(Calendar.HOUR_OF_DAY);
70            mMinute = c.get(Calendar.MINUTE);
71
72            // Launch Time Picker Dialog
73            TimePickerDialog timePickerDialog = new TimePickerDialog(this,
74                    new TimePickerDialog.OnTimeSetListener() {
75
76                        @Override
77                        public void onTimeSet(TimePicker view, int hourOfDay,
78                                              int minute) {
79
80                            txtTime.setText(hourOfDay + ":" + minute);
81                        }
82                    }, mHour, mMinute, false);
83            timePickerDialog.show();
84        }
85    }
86}
87
Alexandra
29 Apr 2017
1@NonNull
2@Override
3public Dialog onCreateDialog(Bundle savedInstanceState) {
4    Calendar calendar = Calendar.getInstance();
5    int year    = calendar.get(Calendar.YEAR);
6    int month   = calendar.get(Calendar.MONTH);
7    int day     = calendar.get(Calendar.DAY_OF_MONTH);
8
9    DatePickerDialog dialog = new DatePickerDialog(getContext(), listener, year, month, day);
10    Field mDatePickerField;
11    try {
12            mDatePickerField = dialog.getClass().getDeclaredField("mDatePicker");
13            mDatePickerField.setAccessible(true);
14    } catch (Exception e) {
15            e.printStackTrace();
16    }
17    dialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);
18    return dialog;
19}
queries leading to this page
monthdialog in android with javadatepickerdialog set date androidandroid studio button to select datemaking datepicker dialog androidhow to let user pick date and time androiddatepickerdialog set max date todayandroid datetime picker dialogdate dialog androidandroid datepicker dialoghow to set limit for date picker androidandroid studio select date dialogdatepickerdialog in androidxdatepickerdialogset min date in datepicker dialog androiddate time picker widget androidandroid show datepicker as a dialogdate select from box in android studiodatepicker dialogset minimum time in timepickerdialog androidtimepickerdialog android allows whatdatepickerdialog to view androidadult datedialog in android studiohow to show date picker dialog in androidrxjava android tutorialdate picker dialog in androiddatepickerdialog android exampleandroid datepickerdialog kotlinin android date listener should open calender as set datedatepickerdialog androidxml datepicker android set min dateandroid contextmenucalendar date selection in androiddatepickerdialog set min date androidandroid datepickerdialog onselectdatetime picker dialog androiddatepickerdialog android studiodate picker dialog max dateandroid datepickerdialog tutorialdate pickerdiaglog androiddialogue date button android studiosoundpool android studiodatepickerdialog android in fragmentandroid datepickerdialogcalander picker androdi set min and max dateandroid datepickerdialog date rangeandroid calendar set max datetimepickerdialog androidhow to get date dialog from custom dialogandroid studio datepickerdialog exampleandroid datepicker exampletoday date picker in android programmaticallyopen calendar dialog in androidshow selected date on dialog androidandroid date picker dialoggeysermc for mandroid how to use date picker dialoghow to set minimum 7 days range in datepicker androidhow to create date picker for android applicationgeysermc for androidandroid dialogdatepickerkotlin android game tutorialdatepickerdialog android activityandroid preloaderandroid studio date picker dialogandroid datepicker dialog exampledatepicker android exampleandroid timepickerdialogdatepickerdialog in android studioandrodi date picker dialogdatepicker androidandroid timepickerdialog exampledatepickerdialog in androidandroid fragment datepickerdialogandroid storandroid datepickerdialog 3a set min and max date for selectiondatepickerdialog set min dateandroid datepickerdialog set min datehow to set minimum date on date picker dialogdate dialog android exampleandroid open date picker dialogdatetimepicker dialog androidandroid datepickerdialog setbackgrounddate picker dialog on date setdate picker dialogs in androidhow to show min and max date in calender in androidandroid date picker dialog exampletimepickerdialog android exampleandroid datepickerdialog exampledatepicker in dialog androiddate picker dialog androidappcompat v7 library for android studioandroid dialog date xmldate xml adnroiddatepickerdialog android setondatesetlistenermax date in android studiodatapickerdialogcalendar dialog androidandroid datepickerdialog spinnerdatepicker dialog androidtimepickerdialog android studiodatepicker dialog in androiddatepickerdialog andoridtimepickerdialog set min time androidset mindate and maxdate in datepicker androidsubstratum ios emoji android 9android setvisibility programaticallyupdate datepickerdialog androiddatepicker mindate today androidhow to show datepickerdialog on button clickandroid date picker exampleshow date picker dialog androidandroid datepicker set mindate todayhow to open date dialog box in android on click of text viewdatepickerdialog android in fragment interface datepickerandroiddatepicker dialog importhow to use on date picker dialog in androidandroid open timepicker dialog after datepcikerdatepickerdialog dialog classes in android 3f 2aandroid datepickerdialog from datecreate datepickerdialog in android studiodatepickerdialog set max date android codeandroid imagebutton vs buttonandroid datepickerdialog