When edittext is set in Android to get the focus, the keyboard is not displayed.

Source: Internet
Author: User

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.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.