hide Keyboard for view Responsible For Keyboard - Android android.view.inputmethod

Android examples for android.view.inputmethod:InputMethodManager

Description

hide Keyboard for view Responsible For Keyboard

Demo Code

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

public class Main{

    public static void hideKeyboard(Activity activity,
            View viewResponsibleForKeyboard) {
        InputMethodManager imm = (InputMethodManager) activity
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(/*from  w w w . j  a v  a  2 s  .  c o m*/
                viewResponsibleForKeyboard.getApplicationWindowToken(), 0);
    }

}

Related Tutorials