SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private void initDateTextView() {
  2.     dateTextView.setOnClickListener(new View.OnClickListener() {
  3.         @Override
  4.         public void onClick(View arg0) {
  5.             showDialog(DATE_DIALOG_ID);                
  6.         }            
  7.     });
  8. }
  9.  
  10. @Override
  11. protected Dialog onCreateDialog(int id) {
  12.     switch (id) {
  13.     case DATE_DIALOG_ID:
  14.        // set date picker as current date
  15.        return new DatePickerDialog(this, datePickerListener,
  16.                      this.year, this.month, this.date);
  17.     }
  18.     return null;
  19. }
  20.  
  21. @Override
  22. protected void onPrepareDialog(int id, Dialog dialog) {
  23.     switch (id) {
  24.     case DATE_DIALOG_ID:
  25.         ((DatePickerDialog)dialog).updateDate(this.year, this.month, this.date);
  26.     }        
  27. }
  28.  
  29. private static final int DATE_DIALOG_ID = 0;
  30. private final DatePickerDialog.OnDateSetListener datePickerListener = new DatePickerDialog.OnDateSetListener() {
  31.     // When dialog box is closed, below method will be called.
  32.     public void onDateSet(DatePicker view, int selectedYear, int selectedMonth, int selectedDay) {
  33.         Log.i("CHEOK", selectedYear + ", " + selectedMonth + ", " + selectedDay);
  34.     }
  35. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top