Java tutorial
//package com.java2s; import android.app.Activity; import android.content.Context; import android.view.View; import android.view.inputmethod.InputMethodManager; public class Main { public static void hideSoftKeyboard(View view) { if (view == null) return; View mFocusView = view; Context context = view.getContext(); if (context != null && context instanceof Activity) { Activity activity = ((Activity) context); mFocusView = activity.getCurrentFocus(); } if (mFocusView == null) return; mFocusView.clearFocus(); InputMethodManager manager = (InputMethodManager) mFocusView.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); manager.hideSoftInputFromWindow(mFocusView.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }