0

I have a URL where User can Input in a Field.

When I open that URL with the Android Browser and click in the Field the Virtual Keyboard pops up. When I open the same URL with my WebView and click in the Field the Virtual Keyboard does NOT appear?!

What Do I have to do? my code is below

LayoutInflater factory = LayoutInflater.from(InviteFriends.this); textEntryView = factory.inflate(R.layout.link, null);

        builder = new AlertDialog.Builder(InviteFriends.this);
        builder.setTitle("Web view");
        builder.setView(textEntryView);

        wvLink = (WebView) textEntryView.findViewById(R.id.wv);


        wvLink.getSettings().setJavaScriptEnabled(true);
        wvLink.loadUrl("http://www.google.com");
        wvLink.requestFocus(View.FOCUS_DOWN);

        wvLink.setWebViewClient(new WebViewClient() 
        {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) 
            {
                view.loadUrl(url);
                return true;
            }
        });





        builder.setNegativeButton("oK",
                new DialogInterface.OnClickListener() {
                    public void onClick(
                            DialogInterface dialog,
                            int which) { 
                        try {
                            if (type == 0) {


                              }

                        } catch (Exception e)
                            {
                                e.printStackTrace();
                            }

                    }
                });


        alert = builder.create();

        alert.show();

Thanks in advance

Nirav Modh
  • 757
  • 1
  • 8
  • 18

2 Answers2

1

So if I understand correctly, you are showing that webpage in an AlertDialog, right? Well, I just had that problem a few days ago, and in the end I solved it by creating a custom Dialog. Custom Dialog is not affected by the WebView bug, and the AlertDialog is. So your solution would look sth like this:

Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.dialog);
dialog.setTitle("Web view");
dialog.setCancelable(true);

dialog.show();

WebView vw = (WebView) dialog.findViewById(R.id.wv);

You would also need to define layout for the dialog with a WebView and a Button inside.

Community
  • 1
  • 1
0

This may be the same problem discussed at WebView textarea doesn't pop up the keyboard

The solution appears to be :

The problem was that webview wasn't getting focus when it was loaded hence using

webView.requestFocus(View.FOCUS_DOWN);

solved the prblem.

Hope this helps,

Phil Lello

Community
  • 1
  • 1
Phil Lello
  • 8,377
  • 2
  • 25
  • 34
  • This may be a 'known bug' described here http://code.google.com/p/android/issues/detail?id=7189, there are some hacks on that thread that may help – Phil Lello Apr 08 '11 at 15:23