toggle Soft Input - Android User Interface

Android examples for User Interface:Input Method

Description

toggle Soft Input

Demo Code


//package com.java2s;

import android.content.Context;

import android.view.View;

import android.view.inputmethod.InputMethodManager;

public class Main {
    public static void toggleSoftInput(Context context, View view,
            boolean shouldShow) {
        if (context == null) {
            return;
        }/*from  w ww  . j a  v  a  2  s .  c  o m*/

        InputMethodManager im = (InputMethodManager) context
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        if (shouldShow) {
            im.showSoftInput(view, InputMethodManager.SHOW_FORCED);
        } else {
            im.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
    }
}

Related Tutorials