Java tutorial
//package com.java2s; import android.content.Context; import android.view.inputmethod.InputMethodManager; public class Main { /** * Toggle Soft Input. * @param context */ public static void toggleSoftInput(Context context) { InputMethodManager inputManager = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_IMPLICIT_ONLY); } /** * Toggle Soft Input. * @param context * @param showFlags */ public static void toggleSoftInput(Context context, int showFlags) { InputMethodManager inputManager = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.toggleSoftInput(showFlags, InputMethodManager.HIDE_IMPLICIT_ONLY); } /** * Toggle Soft Input. * @param context * @param showFlags * @param hideFlags */ public static void toggleSoftInput(Context context, int showFlags, int hideFlags) { InputMethodManager inputManager = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.toggleSoftInput(showFlags, hideFlags); } }