Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.os.Handler; import android.view.View; import android.view.inputmethod.InputMethodManager; public class Main { public static void hideSoftKeyBoard(Context context, final View... views) { try { final InputMethodManager imm = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); new Handler().postDelayed(new Runnable() { @Override public void run() { try { if (views != null) { for (View view : views) { if (view != null) { imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } } } } catch (Exception e) { } } }, 200); } catch (Exception e) { } } public static void hideSoftKeyBoard(InputMethodManager imm, View... views) { if (views != null && imm != null) { for (View view : views) { if (view != null) { imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } } } } }