By default, when edittext gets the focus, a soft keyboard will pop up. If you want to achieve this, a dialog box will pop up directly, like a time dialog box, instead of a soft keyboard, how can you disable the card to bring up a soft keyboard?
Method: setinputtype (inputtype. type_null) of the edittext instance is called in oncreate (). The Android: inputtype = "?? ",?? You can.
/** Init date edittext .*/
View. ontouchlistener dateedittextontouchlistener = new edittextontouchlistener (
Date_dialog );
Mdateedittext. setontouchlistener (dateedittextontouchlistener );
Mdateedittext. setinputtype (inputtype. type_null );
/** Init time start/end edittext .*/
View. ontouchlistener timestartedittextontouchlistener = new edittextontouchlistener (
Time_start_dialog );
Mtimestartedittext. setontouchlistener (timestartedittextontouchlistener );
Mtimestartedittext. setinputtype (inputtype. type_null );
View. ontouchlistener timeendedittextontouchlistener = new edittextontouchlistener (
Time_end_dialog );
Mtimeendedittext. setontouchlistener (timeendedittextontouchlistener );
Mtimeendedittext. setinputtype (inputtype. type_null );
Private class edittextontouchlistener implementsview. ontouchlistener {
Private int dialogid = 0;
Public edittextontouchlistener (INT dialogid ){
This. dialogid = dialogid;
}
@ Override
Public Boolean ontouch (view V, motionevent event ){
Showdialog (dialogid );
Return false;
}
}
To enable the pop-up dialog box, if onclicklistener is used instead of the above ontouchlistener, there is a phenomenon: When edittext never gets the focus until the first time it gets the focus, the dialog box is not displayed, the edittext dialog box is displayed only when the edittext has the focus. However, if onclicklistener is not set but is set to ontouchlistener, the dialog box is displayed when the focus is obtained for the first time.
Note: The above Source Code does not include:
/** Invoked by showdialog indirectly .*/
Protected dialog oncreatedialog (int id ){
......
}
This oncreatedialog is released after showdialog is called. For details, see the call process triggered by showdialog in activity. Class.