title: EditText & onFocusChangeListener
body: <p><br>
  1st of all I wanna thank you all for your great help. I'm a newby and stackoverflow answered most of my questions with already existing answers :-)</p>
  
  <p>For my current project I want to create a kind of a calendar entry and the user has to set a date and time for this entry.
  I decided to have EditText and want to open the picker @OnFocus on EditText (I know about the discussions if this makes sense or not but I think it makes sense to do so).</p>
  
  <p>I have two issues now:<br>
  1) I don't get the OnFocusListener to work :-(<br>
  2) The time picker is always am/pm format though in the EditText it writes 24h format. My device is set to 24h and I don't get the time picker to use 24h, dependent on the device settings. I know it can be set to always be 24h but I think this is confusing for other countries not using 24h so it should be device setting dependent.</p>
  
  <p>I hope you can help me and fix my hopefully not so messy code.
  Thanks in advance!</p>
  
  <p>Here's my code:</p>
  
  <pre><code>public class Test extends ActionBarActivity implements OnFocusChangeListener {
  
  EditText editText, txtDate, txtTime;
  Button button, btnDate;
  
  // Variable for storing current date and time
  private int mYear, mMonth, mDay, mHour, mMinute;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_test);
  
      if (savedInstanceState == null) {
          getSupportFragmentManager().beginTransaction()
                  .add(R.id.container, new  PlaceholderFragment()).commit();
      }
  
  // Force keyboard to open as request focus doesn’t open keyboard
      InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
  
  // Date &amp; Time Picker Stuff
   txtDate = (EditText) findViewById(R.id.etDate);
      txtTime = (EditText) findViewById(R.id.etTime);
  
      txtDate.setOnFocusChangeListener(new OnFocusChangeListener());
      txtTime.setOnFocusChangeListener(new OnFocusChangeListener());
  
  }
  
  @Override
  public void onFocusChange(View v, boolean hasFocus) {
  
      if (v == txtDate) {
  
          // Process to get Current Date
          final Calendar c = Calendar.getInstance();
          mYear = c.get(Calendar.YEAR);
          mMonth = c.get(Calendar.MONTH);
          mDay = c.get(Calendar.DAY_OF_MONTH);
  
          // Launch Date Picker Dialog
          DatePickerDialog dpd = new DatePickerDialog(this,
                  new DatePickerDialog.OnDateSetListener() {
  
                      @Override
                      public void onDateSet(DatePicker view, int year,
                              int monthOfYear, int dayOfMonth) {
                          // Display Selected date in edit text
                          txtDate.setText(dayOfMonth + "-"
                                  + (monthOfYear + 1) + "-" + year);
  
                      }
                  }, mYear, mMonth, mDay);
          dpd.show();
      }
      if (v == txtTime) {
  
          // Process to get Current Time
          final Calendar c = Calendar.getInstance();
          mHour = c.get(Calendar.HOUR_OF_DAY);
          mMinute = c.get(Calendar.MINUTE);
  
          // Launch Time Picker Dialog
          TimePickerDialog tpd = new TimePickerDialog(this,
                  new TimePickerDialog.OnTimeSetListener() {
  
                      @Override
                      public void onTimeSet(TimePicker view, int hourOfDay,
                              int minute) {
                          // Display Selected time in edit text
                          txtTime.setText(hourOfDay + ":" + minute);
                      }
                  }, mHour, mMinute, false);
          tpd.show();
      }
   }
  </code></pre>