hide Keyboard - Android Android OS

Android examples for Android OS:Keyboard

Description

hide Keyboard

Demo Code

/*******************************************************************************
 * Copyright (c) 2012 Vincenzo Marzano./*from w  ww. j av a2  s.  c o  m*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     Vincenzo Marzano - initial API and implementation
 ******************************************************************************/
//package com.java2s;

import android.content.Context;

import android.view.View;

import android.view.inputmethod.InputMethodManager;

public class Main {
    public static void hideKeyboard(Context c, View v) {
        InputMethodManager mgr = (InputMethodManager) c
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        mgr.hideSoftInputFromInputMethod(v.getWindowToken(), 0);
    }
}

Related Tutorials