DatePickerDialog Soft Keyboard Type Not Affected

I use DatePickerDialog in my application, and my problem is that when I try to change the "Day", a soft keyboard appears and shows the numbers, and the carriage in front of the number. When I click the numbers, it does not replace what is already in the "Day" field. Only if I go to the end of the number in the "Day" field and delete it (the return space on the soft keyboard), and then enter the number, it will work.

Why is this happening? Why doesn't he redefine what already exists?

This code displays a dialog box:

protected Dialog onCreateDialog(int id)
{
    Dialog ReturnDialog = null;

    switch (id)
    {
    case DATE_DIALOG_ID:        
        ReturnDialog = new DatePickerDialog(this, mDateSetListener, Year, Month - 1,  Day );
        break;
    }
    return ReturnDialog;
}

Then I call it from onClickListener ()

showDialog( DATE_DIALOG_ID );

What am I doing wrong?

+3
source share
2 answers

, ( ), . A DatePickerDialog DatePicker, NumberPicker (, , ). NumberPicker ImageViews EditText . EditText, /, , .

, , Android, EditTexts. , DatePicker Android, DatePickerDialog ( Honeycomb, API 11).

, DatePickerDialog , , .

+1

" , ", OnGlobalFocusChangeListener DatePickerDialog :

private final OnGlobalFocusChangeListener mFocusCheck = new OnGlobalFocusChangeListener() {
    @Override
    public void onGlobalFocusChanged(View oldFocus, View newFocus) {
        if (newFocus != null && newFocus instanceof EditText) {
            final EditText editText = (EditText) newFocus;
            editText.selectAll();
        }
    }
};

@Override
protected Dialog onCreateDialog(int id) {
    Dialog dialog = null;

    switch (id) {
        case DIALOG_ID:
            dialog = new DatePickerDialog(this, mDateSetListener, year, month - 1, day) {
                @Override
                public void setView(View view) {
                    super.setView(view);
                    view.getViewTreeObserver().addOnGlobalFocusChangeListener(mFocusCheck);
                }
            };
            break;
    }

    return dialog;
}

, Android, ( , , DatePicker NumberPicker EditText),.

, , Android 4.0 4.1 NumberPicker ( , 4.0, 4.1 - ).

0
source

All Articles