How to open numeric keyboard on page load on an Android Rhomobile app?

// Expert user has replied.
D Douglas Lise 3 years ago
143 3 0

I have a rhomobile application where I need to manually open the keyboard when the user enters on a page.
My page has an input text as the first field where the user should input a number, so the input is of number type.
As Android OS does not allow you to use autofocus (and open the keyboard) then I needed to write a native extension to manually open the keyboard when that page is requested.
I achieve the intent of show the soft keyboard, but I am not able to switch/choose to show the numeric keypad. It always shows the last used keyboard type.

My HTML:

   

Native extension code, called on page request:

    Context context = com.rhomobile.rhodes.util.ContextFactory.getUiContext();
    InputMethodManager inputMethodManager=(InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.showSoftInput(view, 0);

I need this to work only in Android by now.

Can anyone help me?
Thanks in advance.

Please register or login to post a reply

3 Replies

B Bryn Cranswick

Douglas,

Have you tried using JS/Jquery to focus on the input when the document is ready? It's a good idea to add a delay (setTimeout) as it wasn't working for me without it.

$(document).ready(function() {
       //delay by 500ms before focusing on input so that android number keypad pops up correctly
       var input = $(".inputClassToFocusOn");
       setTimeout(function() {
            input.focus();
       },500);
  });

B Bryn Cranswick

It would be really nice to see a fix for this issue...

There have been people mentioning similar Android numeric keyboard issues since 2012:
https://groups.google.com/forum/#!msg/rhomobile/7AVy4_n6BSY/mUOCKxYLuKgJ

It's pretty fundamental as it adds an extra button press on many of our workflows (switching from text->number entry).
Our customers have commented on how they wish they could use the number soft keyboard for entering quantities, prices and discounts.
Using the piddly number keys on the text SIP is also very frustrating.

As mentioned by Douglas if you have a text input on the previous screen and move to the next screen which has a number field, the text soft keyboard launches
instead of the numeric.
If you are trying to enter a decimal on Android using the number keyboard, forget it. It just doesn't happen.

All issues seem to be fixed when you remove " - motorola_browser" from your build.yml but then you lose all the nice -webkit styling options.

Please please please get onto fixing this..

R Robert Galvin

Try:

input type="tel"

CONTACT
Can’t find what you’re looking for?