Wednesday, November 7, 2012

Show or Hide soft keyboard on opening a dialog or activity in android

For showing the soft keyboard on entering into the activity or to the dailog we can use this coding.

InputMethodManager show = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

and for hiding the keyboard

InputMethodManager hide = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

If you want virtual Keyboard on start of activity. Try below code.

 Your Virtyual key board open on starting of activity.


 **YOUR_VIEW**.postDelayed(new Runnable() {
            public void run() {
                InputMethodManager keyboard = (InputMethodManager)
                keyboard.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);