问题描述
我有一个Android应用程序,这将打开的WebView一个jQuery Mobile的网站。本页面包含了几乎20表单字段。键盘效果很好,我可以给输入,直到我键入 6位数在输入[类型=号]
箱里面有一个最大长度= 5
属性。这款键盘后停止工作。当我点击一个元素,得到集中和键盘的弹出窗口,但它没有从键盘值
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 ?
主要活动
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);
在清单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中的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>
和日志
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: view=android.webkit.WebView@41da5668
05-03 12:58:02.572: V/InputMethodManager(5044): Starting input: tba=android.view.inputmethod.EditorInfo@41ddf148 ic=android.webkit.WebViewClassic$WebViewInputConnection@41e0d6f0
05-03 12:58:02.573: V/InputMethodManager(5044): START INPUT: android.webkit.WebView@41da5668 ic=android.webkit.WebViewClassic$WebViewInputConnection@41e0d6f0 tba=android.view.inputmethod.EditorInfo@41ddf148 controlFlags=#0
05-03 12:58:02.574: V/InputMethodManager(5044): Starting input: Bind result=InputBindResult{com.android.internal.view.IInputMethodSession$Stub$Proxy@41dada48 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
我的不会有这个问题在iball幻灯片( 4.0.3 ),我在HCL我连接-V3( 4.1.2 )。由于这是一个私人的应用为我们的员工,我们将利用这个对这些药片
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
推荐答案
如果您的布局有TabHost(或类似的布局或视图),TabHost的孩子可能会扰乱你的WebView的焦点。
If your layout have TabHost (or similar layout or view),TabHost's child may disturb your webview's focus.
我有同样的问题,我将这些观点的可成为焦点ATTR为假,并能正常工作。
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);
}
这篇关于验证后,Android键盘不工作的WebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!