1

I have an issue in Android Jelly Bean version where the web view refuses input in text boxes.

Tried with a simple page with only one input tag as given below. In android browser the page works fine, both keypress and blur events fire. In Web view only the blur event fires and the text is not appearing.

I tried the webview settings mentioned in the link given below.

Why is Android WebView refusing user input?

There is a known defect in jelly bean for text fields with 'maxlength' attribute. I am not using max length .

<input id="phoneNumber" 
        name="phoneNumber" type="text" value="test" onblur="alert('lost focus');" onkeypress="alert('key press');"/>

Can anyone throw some light on how to resolve this issue??

Community
  • 1
  • 1
Hari Nair
  • 96
  • 1
  • 1
  • 10
  • If you remove the `onkeypress` (and maybe the `onblur`), does it work? – Cat Nov 05 '12 at 22:00
  • Eric, They don't work without the onkeypress and onblur handlers also. I added those while debugging, and retained them in the post as I found the onkeypress is not called from webview, while it works in browser. – Hari Nair Nov 05 '12 at 23:55

1 Answers1

0

I had the same problem and my research results with this:

As there is devices with no physical buttons, there is the navigation Bar with the relevant buttons.

So, if a physical 'back' button was pressed the onKeyDown method was called, and i guess they had to attach this method to the 'back' button on the Navigation Bar.

Any way, it results with the call to the onkeyDown and onkeyUp methods when the soft keyboard is being used, and if for some reason you override it you have to make sure you call super so it will be able to process the keys event:

@Override
public boolean onKeyDown(int keyCode,  KeyEvent event) 
{
    if (keyCode == KeyEvent.KEYCODE_BACK) 
    {
        // Do Somthing...
           return true;
    }
    return super.onKeyDown(keyCode, event);
}

Hope it helps.

Eitan
  • 1,012
  • 7
  • 25