title: How do I lauch a DatePicker Fragment on single click for EditText?
body: <p>I have one minor issue to fix with a DatePicker Fragment. The user clicks on an EditText line on the UI screen and that immediately launches a DatePcker fragment on the first click. The user selects a date and the code sets the date on the EditText line. The focus is returned to the EditText line with a blinking cursor.</p>
  
  <p>Now if the user navigates away to another EditText line and then returns to the DatePicker EditText line to select a different date, it takes two clicks to launch the Picker again. The first click gets focus and the second click launches the Picker and I am trying to launch the Picker on the first click.  Note the emptiness test for "onFocusChange" is to ensure the fragment dialog does not launch when a date has been set and then an orientation change occurs.</p>
  
  <p>partial Activity file:</p>
  
  <pre><code>...
  fListenerEditText.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              DialogFragment newFragment = new DatePickerFragment();
              newFragment.show(getSupportFragmentManager(), "datePicker");
              // The below line gets the Floating Label color to switch back to the primary Hint color.
              // Also allows the back button code to work correctly, to go back to the previous activity and clear
              // the soft keyboard with one press, not two.
              fListenerEditText.requestFocus();
          }
      });
  
      fListenerEditText.setOnFocusChangeListener(new OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
              // If fListernerEditText gains focus then launch DatePicker
              // else nothing is done is fListenerEditText loses focus.
              // Also the length() test is a test for emptiness;  that is, only display
              // the DatePicker dialog if the EditText is empty.  That way, if there is already a
              // a date set in the EditText line and an orientation change occurs, the new Activity
              // and Fragment won't re-launch the DatePicker dialog again because the length() test won't show empty.
              if (hasFocus &amp;&amp; (fListenerEditText.getText().length() == 0)) {
                  DialogFragment newFragment = new DatePickerFragment();
                  newFragment.show(getSupportFragmentManager(), "datePicker");
                  // The below line gets the Floating Label color to switch back to the primary Hint color.
                  // Also allows the back button code to work correctly, to go back to the previous activity and clear
                  // the soft keyboard with one press, not two.
                  fListenerEditText.requestFocus();
              }
          }
      });
  </code></pre>