Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Licensed Materials - Property of IBM
 *  Copyright IBM Corporation 2015. All Rights Reserved.
 */

import android.content.Context;

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

public class Main {
    /**
     * Dismisses the soft keyboard if it's present on the screen, otherwise this call is silent.
     *
     * @param context
     * @param editText the EditText that the soft keyboard is "attached" to
     */
    public static void closeSoftKeyboard(Context context, EditText editText) {
        InputMethodManager manager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        manager.hideSoftInputFromWindow(editText.getWindowToken(), 0);
    }
}