Java tutorial
//package com.java2s; /** * Copyright (c) 2012 Todoroo Inc * * See the file "LICENSE" for the full license governing this code. */ import android.content.Context; import android.view.View; import android.view.inputmethod.InputMethodManager; public class Main { /** * Dismiss the keyboard if it is displayed by any of the listed views * @param views - a list of views that might potentially be displaying the keyboard */ public static void hideSoftInputForViews(Context context, View... views) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); for (View v : views) { imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } } }