Android keyboard not working in webview after a validation

I have an android application , which opens a Jquery mobile site in webview . This page contains almost 20 form fields.Keyboard works well , i can able to give input until i type 6 digit number in a input[type=number] box which has a maxlength=5 attribute. After this keyboard stops working . when i click a element , get focused and keyboard popups but it is not getting the value from keyboard

what might be the problem ? how to get rid of this ?

Main Activity

        mWebview  = new WebView(this);
        mWebview.getSettings().setJavaScriptEnabled(true);
        mWebview.getSettings().setGeolocationEnabled(true);       
        mWebview.getSettings().setJavaScriptCanOpenWindowsAutomatically (true);
        mWebview.getSettings().setSupportMultipleWindows(true);
        mWebview.getSettings().setCacheMode(mWebview.getSettings().LOAD_NO_CACHE);
        mWebview.addJavascriptInterface(new WebAppInterface(this), "Android");
        mWebview.loadUrl(WebUrl);
        setContentView(mWebview);

In Manifest XML

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

HTML in webview

<div class="clsRow">
    <div class='clstdLeft' style='width:50%;'>
        <label>Additional Discount </label>
    </div>
    <div class='clstdRight'>
        <label>
            <input type='number' maxlength=5  value=0>
        </label>
    </div>
</div><div class='clear'>   </div>

And log is

05-03 12:58:01.593: I/SurfaceTextureClient(5044): [0x53289e48] frames:4, duration:1.222000, fps:3.271073
05-03 12:58:02.570: E/SpannableStringBuilder(5044): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
05-03 12:58:02.571: E/SpannableStringBuilder(5044): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
05-03 12:58:02.572: V/InputMethodManager(5044): Starting input: [email protected]
05-03 12:58:02.572: V/InputMethodManager(5044): Starting input: [email protected] [email protected]
05-03 12:58:02.573: V/InputMethodManager(5044): START INPUT: [email protected] [email protected] [email protected] controlFlags=#0
05-03 12:58:02.574: V/InputMethodManager(5044): Starting input: Bind result=InputBindResult{[email protected]8 com.android.inputmethod.latin/.LatinIME #166}
05-03 12:58:02.574: W/IInputConnectionWrapper(5044): endBatchEdit on inactive InputConnection
05-03 12:58:02.710: I/SurfaceTextureClient(5044): [0x53289e48] frames:3, duration:1.111000, fps:2.699259
05-03 12:58:04.126: I/SurfaceTextureClient(5044): [0x53289e48] frames:3, duration:1.421000, fps:2.109934

I am not having this problem in iball slide (4.0.3), I have a problem in HCL me connect-v3 (4.1.2) . As it is a private application for our employees we are going to use this on these tablets

Answers:

Answer

If your layout have TabHost (or similar layout or view), TabHost's child may disturb your webview's focus.

I have same problem and I set these view's focusable attr to "false" and works fine.

for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
  tabHost.getTabWidget().getChildAt(i).setFocusable(false);
}
Answer

Try change your "maxlength=5" to onkeypress="if(this.value.length > 4) return false;"

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.