auto Focus Show Soft Input - Android Phone

Android examples for Phone:KeyBoard

Description

auto Focus Show Soft Input

Demo Code


//package com.java2s;
import android.content.Context;

import android.os.Handler;

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

public class Main {

    public static void autoFocusShowSoftInput(View v, final Context context) {
        v.setFocusable(true);// w  ww .ja va2s  . c  om
        v.setFocusableInTouchMode(true);
        v.requestFocus();
        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                // TODO Auto-generated method stub
                showSoftInput(context);
            }
        }, 830);
    }

    public static void showSoftInput(Context context) {
        InputMethodManager imm = (InputMethodManager) context
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
    }
}

Related Tutorials