7

We have an app that is using webview to present some HTML pages. This HTML page has input type and we were using input-type = number as we only accept numbers with decimal in this field. So the numeric android keypad appeared with the decimal point.

The problem is the Samsung devices updated to Android 4.3. Now the decimal point is missing from the numeric keyboard.

So we need to put the common keyboard in order to have the decimal point. The problem is that the common keypad appears with letters and we want by default that the keypad appears on the numbers part of the keyboard in order to make more user friendly. Like this.

enter image description here

How can we achieve this??

EDIT: Maybe i haven't explain well. The problem is on a HTML page not in an android TextView So all the android:type answers are not useful.

Community
  • 1
  • 1
isra60
  • 512
  • 1
  • 6
  • 18
  • can you see if this one solves your problem ?http://stackoverflow.com/questions/19208491/edittext-with-inputfilter-assigned-decimal-separator-hidden-in-landscape-mode – PedroAGSantos Jan 22 '14 at 10:52
  • @subspider That is a TextView related solution not HTML input-type – isra60 Jan 22 '14 at 22:25

2 Answers2

6

Subclassing WebView and overriding onCreateInputConnection method does the trick of getting decimal separator into soft keyboard.

Another option is to change HTML input type from "number" to "tel", but that allows user to enter additional characters like "*" and "#".

This seems to be Samsung 4.3 specific issue.

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {

    InputConnection connection = super.onCreateInputConnection(outAttrs);

    if ((outAttrs.inputType & InputType.TYPE_CLASS_NUMBER) == InputType.TYPE_CLASS_NUMBER)
    {
        outAttrs.inputType |= InputType.TYPE_NUMBER_FLAG_DECIMAL;
    }

    return connection;
}
Erkki Nokso-Koivisto
  • 1,203
  • 15
  • 19
0

You can set for keyboard as InputType number by overriding in class file of the webview laypout you are using: foloow this code

override fun onCreateInputConnection(outAttrs: EditorInfo): InputConnection {
    val inputConnection = BaseInputConnection(this, false)
    outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE
    outAttrs.inputType = EditorInfo.TYPE_CLASS_NUMBER
    return inputConnection
}

It might help you

Eshan Chattaraj
  • 368
  • 1
  • 6
  • 19