Back to project page Common-Library.
The source code is released under:
Apache License
If you think the Android project Common-Library listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.morgan.library.utils; //ww w. j ava2 s . com import android.content.Context; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import com.morgan.library.app.APPContext; /** * ??????????????? * * @author Morgan.Ji * */ public class KeyBoardUtils { public static void showKeyBoard(final EditText editText) { if (editText == null) { return; } editText.requestFocus(); editText.post(new Runnable() { public void run() { InputMethodManager imm = (InputMethodManager) APPContext .getContext().getSystemService( Context.INPUT_METHOD_SERVICE); imm.showSoftInput(editText, InputMethodManager.RESULT_UNCHANGED_SHOWN); } }); } public static void hideSoftInput(EditText editText) { if (editText == null) { return; } InputMethodManager inputMethodManager = (InputMethodManager) APPContext .getContext().getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN); } }