Basic usage analysis of soft keyboard in Android programming _android

Source: Internet
Author: User

This article illustrates the basic usage of soft keyboards in Android programming. Share to everyone for your reference, specific as follows:

Call the following code: (The first call shows, then the call is hidden, so repeated), this refers to the activity

Inputmethodmanager IMM = (inputmethodmanager) this.getsystemservice (context.input_method_service);
Imm.togglesoftinput (0, inputmethodmanager.hide_not_always);
Imm.showsoftinput (MyView, inputmethodmanager.show_implicit);

Show hidden soft keyboard individually:

Show:

Inputmethodmanager IMM = (inputmethodmanager) this.getsystemservice (context.input_method_service);
Imm.showsoftinput (myview, 0);

Hide:

Imm.hidesoftinputfromwindow (View.getwindowtoken (), 0);

After the program is started, automatically eject the soft keyboard, you can set a time function to achieve, no longer write in OnCreate:

Timer timer = new timer ();
Timer.schedule (New TimerTask () {
@Override public void Run () {
Inputmethodmanager IMM = (Inputmethodmanager) This.getsystemservice (Input_method_service); Imm.togglesoftinput (0, inputmethodmanager.hide_not_always);
Toast.maketext (Chick.this, "show", Toast.length_short). Show ();
}
, 1000);

For more information on Android-related content readers can view the site: "Android View tips Summary", "Android Layout Layout Skills Summary", "Android Development introduction and Advanced Course", " Android Debugging tips and FAQ Solutions Summary, Android Multimedia tips summary (audio, video, audio, etc.), "Android Basic Components Usage Summary" and "Android Control usage Summary"

I hope this article will help you with the Android program.

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.