Android eclipse webview弹出不显示 [英] Android eclipse webview pop up not displaying

查看:152
本文介绍了Android eclipse webview弹出不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个网络应用程序,我使用一个弹出窗口显示一个消息,如果某些东西不工作或只是为了确认某事。我已经在eclipse上制作了一个简单的Android应用程序,通过网页视图使用我的网络应用程序,我面临的问题是,似乎应用程序中的网页视图不支持弹出窗口....我是对的有没有办法在我的应用程序中显示弹出窗口?这是我用于我的网页视图的代码。感谢您提前帮助。

So I have a web app where I use a pop up window to display a message if something is not working or just to confirm something. I have made a simple android app on eclipse to use my web app through a web view, the problem I'm facing is that it seem that the web view inside the app does not support pop up windows.... Am I right or is there a way around to display pop up windows inside my app? here is the code I'm using for my web view. thanks for helping in advance.

    wvp = (WebView) findViewById(R.id.webView1);
    wvp.getSettings().setJavaScriptEnabled(true);
    wvp.setWebViewClient(new WebViewClient());
    wvp.setInitialScale(1);
    wvp.getSettings().setBuiltInZoomControls(true);
    wvp.getSettings().setDisplayZoomControls(false);
    wvp.getSettings().setUseWideViewPort(true); 

所以如果你有同样的问题,这里是解决方案感谢ksasq

So if you have my same problem here is the solution thanks to ksasq

    wvp = (WebView) findViewById(R.id.webView1);
    wvp.getSettings().setJavaScriptEnabled(true);
    wvp.setWebViewClient(new WebViewClient());
    wvp.setWebChromeClient(new WebChromeClient());
    wvp.setInitialScale(1);
    wvp.getSettings().setBuiltInZoomControls(true);
    wvp.getSettings().setDisplayZoomControls(false);
    wvp.getSettings().setUseWideViewPort(true);
    wvp.getSettings().setSupportMultipleWindows(true);
    wvp.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

这使得能够显示我之前的消息弹出窗口的技巧。享受!

this made the trick to be able to show that message pop up window I was after. enjoy!

推荐答案

有一些事情你需要做:


  1. 实现 WebChromeClient.onCreateWindow [1]

  2. 切换 WebSettings.setSupportMultipleWindows [2]为true

  3. 根据新窗口的创建方式,您可能需要启用 WebSettings.setJavaScriptCanOpenWindowsAutomatically [3]

  1. Implement WebChromeClient.onCreateWindow [1]
  2. Toggle WebSettings.setSupportMultipleWindows[2] to true
  3. Depending on how the new window is created, you may need to enable WebSettings.setJavaScriptCanOpenWindowsAutomatically[3]

[1] http://developer.android.com/reference/android/webkit/WebChromeClient.html#onCreateWindow(android.webkit.WebView ,boolean,boolean,android.os.Message)

[1] http://developer.android.com/reference/android/webkit/WebChromeClient.html#onCreateWindow(android.webkit.WebView, boolean, boolean, android.os.Message)

[2] http://developer.android.com/reference/android/webkit/WebSettings.html#setSuppo rtMultipleWindows(boolean)

[3] http://developer.android.com/reference/android/webkit/WebSettings.html#setJavaScriptCanOpenWindowsAutomatically(boolean)

这篇关于Android eclipse webview弹出不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆