Show the pop-up keyboard - Android User Interface

Android examples for User Interface:Input Method

Description

Show the pop-up keyboard

Demo Code


//package com.java2s;

import android.content.Context;

import android.util.Log;

import android.view.View;
import android.view.inputmethod.InputMethodManager;

public class Main {
    /**/*from  w w  w.j a va  2  s . c o  m*/
     * Show the pop-up keyboard
     *
     * @param context Activity/Context
     * @param field   field that requests focus
     */
    public static void showKeyboard(Context context, View field) {
        try {
            field.requestFocus();
            InputMethodManager imm = (InputMethodManager) context
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(field, InputMethodManager.SHOW_IMPLICIT);
        } catch (Exception ex) {
            Log.e("Caffeine",
                    "Error occurred trying to show the keyboard.  Exception="
                            + ex);
        }
    }
}

Related Tutorials