Back to project page mclib.
The source code is released under:
Apache License, Version 2.0 FoundationProjectsPeopleGet InvolvedDownloadSupport ApacheHome ? Licenses Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITION...
If you think the Android project mclib 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 mc.lib.io; /* w w w. ja v a 2 s. c o m*/ import android.app.Activity; import android.content.Context; import android.os.IBinder; import android.view.View; import android.view.inputmethod.InputMethodManager; public class KeyboardHelper { public static void showKeyboard(Context context, View view) { if(context != null && view != null) { InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInputFromWindow(view.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0); } } public static void hideKeyboard(Activity activity) { if(activity != null) { View v = activity.getCurrentFocus(); if(v != null) { IBinder b = v.getWindowToken(); if(b != null) { InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(b, 0); } } } } public static void hideKeyboard(Context context, View view) { if(context != null && view != null) { InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } } }