Hide On Screen Keyboard for EditText - Android User Interface

Android examples for User Interface:EditText

Description

Hide On Screen Keyboard for EditText

Demo Code


//package com.java2s;
import android.app.Activity;
import android.content.Context;

import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;

public class Main {
    /**//from  w  ww .j  av  a 2  s  . c om
     * Hide On Screen Keyboard for EditText
     *
     * @param activity
     *     the activity
     * @param editText
     *     the edit text
     */
    public static void hideOnScreenKeyboardForEditText(Activity activity,
            EditText editText) {
        ((InputMethodManager) activity
                .getSystemService(Context.INPUT_METHOD_SERVICE))
                .hideSoftInputFromWindow(editText.getWindowToken(), 0);
    }
}

Related Tutorials