Java tutorial
//package com.java2s; import android.app.Activity; import android.content.Context; import android.view.View; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; public class Main { public static void hideSoftInput(Context context) { View view = ((Activity) context).getWindow().peekDecorView(); if (view != null) { InputMethodManager inputmanger = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0); } } public static void hideSoftInput(Context context, EditText edit) { edit.clearFocus(); InputMethodManager inputmanger = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputmanger.hideSoftInputFromWindow(edit.getWindowToken(), 0); } }