9

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">
Community
  • 1
  • 1
Martin
  • 790
  • 2
  • 9
  • 24
  • I experience the exact same problem in my project, which contains many views that gain/lose visibility according to the state of the application. When testing the solution "Tapping form field in WebView does not show soft keyboard" on a simple activity with just one WebView the problem is solved. I did try to remove focusability from all other views, but this problem is persistent. a bounty is offered... – Rotemmiz Feb 01 '12 at 11:04

2 Answers2

5

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.

Rotemmiz
  • 7,933
  • 3
  • 36
  • 36
  • hi rotemmiz. could you please share your code ? would be appreciated very much!! greets from austria! – Martin Feb 12 '12 at 16:12
  • Hi there Martin, I would share my code if it could help someone, but the weird keyboard behavior I expereinced was due to several very specific things I did in my app (including running javascript code on every site I load in my webView), Try posting a question with code included, and I will see if i can recognize something with this pattern. – Rotemmiz Feb 12 '12 at 16:32
0

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 :)

Tofeeq Ahmad
  • 11,935
  • 4
  • 61
  • 87
  • For more info see that question--http://stackoverflow.com/questions/5812064/android-emulator-keyboard-not-displaying – Tofeeq Ahmad Feb 02 '12 at 06:23