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