about how to use Inputmethodmanager

Source: Internet
Author: User

Inputmethodmanager is a class for controlling the display or hiding of IME panels (and, of course, other functions).
The way to get Inputmethodmanager is simple.

= (Inputmethodmanager) getsystemservice (Context.input_method_service);

Describes how to use them separately.

1.showSoftInput (view view, int flags) display IME panel

 PackageToken.token;Importandroid.app.Activity;ImportAndroid.content.Context;ImportAndroid.os.Bundle;ImportAndroid.os.IBinder;ImportAndroid.view.View;ImportAndroid.view.ViewGroup;ImportAndroid.view.inputmethod.InputMethodManager;ImportAndroid.widget.Button;ImportAndroid.widget.EditText; Public classTokenactivityextendsActivity {/**Called when the activity is first created.*/EditText et=NULL; Inputmethodmanager IMM=NULL; IBinder IB=NULL; Button BT=NULL; @Override Public voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.main); ET=(EditText) Findviewbyid (R.id.edit); BT=(Button) Findviewbyid (R.id.button); IMM=(Inputmethodmanager) Getsystemservice (Context.input_method_service); }     Public voidAA (View v) {Et.requestfocus ();//imm.showsoftinput (ET, imm. show_forced);//ChenggongImm.showsoftinput (ET, 0);//Imm.hidesoftinputfromwindow (Bt.getwindowtoken (), 0);    }}

The two parameters of this method, Showsoftinput (view view, int flags). View is to display Input Panel on the basis of which view, and before using this method, the view needs to have the focus and can be set by the Requestfocus () method.

2.hideSoftInputFromWindow (ibinder windowtoken, int flags) Hide IME Panel

The code is as follows:

 Public void AA (View v) {       = et.getwindowtoken ();        0);        0);   }

This hides the two parameters in the input box before a parameter can also be written as Et.getwindowtoken ().

Transfer from http://my.oschina.net/jbcao/blog/61035

about how to use Inputmethodmanager

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.