title: Open a DatePickerDialog on Click of EditText takes two clicks
body: <p>I want to open a Calendar on the click of Edit text. After that I want to set the date which the user selects from the Calendar in the edit text. Problem is that, only when I click on the EditText for the second time then the calendar open. Please help me to resolve the issue(<code>why calendar don't open for the first time</code>).</p>
  
  <p><strong>EditText</strong> XML code</p>
  
  <pre><code>&lt;EditText
              android:id="@+id/dateofBirth"
              android:layout_width="290dp"
              android:layout_height="wrap_content"
              android:layout_marginLeft="5dp"
              android:layout_marginTop="10dp"
              android:maxLines="1"
              android:hint="dd/mm/yyyy" /&gt;
  </code></pre>
  
  <p><strong>Activity</strong> Code</p>
  
  <pre><code>public void informationPopUp() {
          final Dialog dialog= new Dialog(MainActivity.this,R.style.Dialog_Fullscreen);
          dialog.setContentView(R.layout.details_dialog); 
          dateofBirth = (EditText)dialog.findViewById(R.id.dateofBirth);
  
          dialog.show();
           myCalendar = Calendar.getInstance();
  
         final DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
  
              @Override
              public void onDateSet(DatePicker view, int year, int monthOfYear,
                      int dayOfMonth) {
                  // TODO Auto-generated method stub
                  myCalendar.set(Calendar.YEAR, year);
                  myCalendar.set(Calendar.MONTH, monthOfYear);
                  myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                  updateLabel();
              }
  
  
          };
  
          dateofBirth.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  showDialog(DATE_DIALOG_ID);
                }
          });
  
      }
       private void updateLabel() {
           String myFormat = "MM/dd/yy"; //In which you need put here
           SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
           dateofBirth.setText(sdf.format(myCalendar.getTime()));
       }
  
       protected Dialog onCreateDialog(int id) {
              final Calendar now = Calendar.getInstance();
  
              switch (id) {
              case DATE_DIALOG_ID:
                  // set date picker as current date
                  DatePickerDialog _date =   new DatePickerDialog(this, date,myCalendar
                          .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
                          myCalendar.get(Calendar.DAY_OF_MONTH)){
                      @Override
  
                      public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth){   
  
                          if (year &gt; now.get(Calendar.YEAR))
  
                              view.updateDate(myCalendar
                                      .get(Calendar.YEAR), myCalendar
                                      .get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH));
  
                          if (monthOfYear &gt; now.get(Calendar.MONTH) &amp;&amp; year == now.get(Calendar.YEAR))
                              view.updateDate(myCalendar
                                      .get(Calendar.YEAR), myCalendar
                                      .get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH));
  
                          if (dayOfMonth &gt; now.get(Calendar.DAY_OF_MONTH) &amp;&amp; year == now.get(Calendar.YEAR) &amp;&amp; 
                                  monthOfYear == now.get(Calendar.MONTH))
                              view.updateDate(myCalendar
                                      .get(Calendar.YEAR), myCalendar
                                      .get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH));
                              }
                  };
                  return _date;
              }
              return null;
          } 
  </code></pre>
  
  <p>I am not understanding what I have done wrong. Please suggest a solution.</p>