Java tutorial
//package com.java2s; import android.content.Context; import android.view.View; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; public class Main { private static InputMethodManager imm; public static void hideSoftInput(Context context, EditText editText) { getInputMethodManager(context).hideSoftInputFromWindow(editText.getWindowToken(), 0); } public static void hideSoftInput(Context context, View view) { getInputMethodManager(context).hideSoftInputFromWindow(view.getWindowToken(), 0); } private static InputMethodManager getInputMethodManager(Context context) { if (imm == null) { imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); } return imm; } }