toggle Soft Input - Android Phone

Android examples for Phone:KeyBoard

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 final void toggleSoftInput(View tokenView, boolean isHide) {
        if (tokenView == null)
            return;
        InputMethodManager inputMethodManager = (InputMethodManager) tokenView
                .getContext()/*from ww w .ja va  2 s  .  c  o m*/
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        if (isHide)
            inputMethodManager.hideSoftInputFromWindow(
                    tokenView.getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);
        else
            inputMethodManager.showSoftInput(tokenView, 0);
    }
}

Related Tutorials