Prachi
Prachi

Reputation: 3672

Android Open number keyboard in android

I've an editBox whose property is set to android:inputType="number". Now, if I exclusively touch the editBox, I get numberkeyboard. But when programatically I make focus, then qwerty keyboard appears.

InputMethodManager m = (InputMethodManager) context
                .getSystemService(Context.INPUT_METHOD_SERVICE);

shows the simple qwerty keyboard. What if I want to open the number keyboard ?

Upvotes: 1

Views: 196

Answers (2)

Pratik Butani
Pratik Butani

Reputation: 62419

To show the keyboard:

InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInput(viewToEdit, 0);

To hide the keyboard:

if (getCurrentFocus() != null) {
    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getApplicationWindowToken(), 0);
}

Upvotes: 1

Ragaisis
Ragaisis

Reputation: 2750

This should help you:

    yourEditText.performClick();

Upvotes: 0

Related Questions