Reputation: 800
I have an Android 3.0 App with a WebView inside. The webview opens an website which uses java script. Opening the Website works fine. But whenever I click on a TextField, the keyboard doesn't appear.
I've already tried: Tapping form field in WebView does not show soft keyboard
but no success. The keyboard seems to appear very shortly and thereafter disappears. From my point of view this is caused by some javascript. This is the html of one of the input fields:
<input id="ToolbarOkCode" class="urEdf2TxtEnbl" type="Text" style="text-align:;width:150px;" value="" name="ToolbarOkCode" lsevents="{'Change':[{'ClientAction':'none'},{'type':'TOOLBARINPUTFIELD'}],'Enter':[{'ClientAction':'submit','PrepareScript':'return its.XControlSubmit();','ResponseData':'delta','TransportMethod':'partial'},{'type':'TOOLBARINPUTFIELD','~XRequest':'X'}]}" lsdata="{0:'',1:'',2:'',3:20,4:200,5:false,6:false,7:true,8:false,9:false,10:'STRING',11:'F4LOOKUP',12:'150px',13:'LEFT',14:false,15:'',16:false,17:false,18:false,19:'AUTO',20:true,21:'NONE',22:'MM/dd/yyyy',23:false,24:'',25:'',26:false,27:false,28:'',29:'NORMAL',30:1,31:false,32:0,33:0}" ct="I" autocomplete="off" ti="0" tabindex="0" maxlength="200">
Upvotes: 9
Views: 1801
Reputation: 7971
I found the solution for my problem, It's pretty specific though, I hope it will help someone sometime...
I extendedWebViewClient
, and overrode few of its functions.
my issue started when I loaded a propitiatory javascript:
on onLoadResource()
. For some reason, doing so caused the whole keyboard abnormality. I moved the script to run on onPageFinished()
and the WebView
acts normally again.
Upvotes: 5
Reputation: 11975
I have used your code and then try to run on android 2.2.It work fine and showing keyboard to enter value.I posting complete code that i run
String str="<input id=\"ToolbarOkCode\" class=\"urEdf2TxtEnbl\" type=\"Text\" style=\"text-align:;width:150px;\" value=\"d\" " +
" name=\"ToolbarOkCode\" lsevents=\"{'Change':[{'ClientAction':'none'},{'type':'TOOLBARINPUTFIELD'}],"+
"'Enter':[{'ClientAction':'submit','PrepareScript':'return its.XControlSubmit();','ResponseData':'delta','TransportMethod':'partial'},"+
"{'type':'TOOLBARINPUTFIELD','~XRequest':'X'}]}\" lsdata=\"{0:'',1:'',2:'',3:20,4:200,5:false,6:false,7:true,8:false,9:false,10:'STRING',11:"+
"F4LOOKUP',12:'150px',13:'LEFT',"+
"14:false,15:'',16:false,17:false,18:false,19:'AUTO',20:true,21:'NONE',22:'MM/dd/yyyy',23:false,24:'',25:'',26:false,27:false,28:'',"+
"29:'NORMAL',30:1,31:false,32:0,33:0}\"" +
"ct=\"I\" autocomplete=\"off\" ti=\"0\" tabindex=\"0\" maxlength=\"200\">";
WebView webView=new WebView(this);
webView.setFocusableInTouchMode(true);
webView.loadData(str, "Text/html","utf-8");
setContentView(webView);
Hope this will help you :)
Upvotes: 0