android开发分享android:webview里面的对话框或popup

如何在对话框或popup窗口中添加Web‰C6;图。

我的web视图保持URL WebView.loadurl()。当视图添加到对话框里,它仍然移动到浏览器。

我一直在android中加载webview的对话框,但没有例子,如何做到这一点? 谢谢

    这里是例子:

    %ignore_pre_1%

    你需要重写setWebViewClient()..

     mWebView = (WebView) view.findViewById(R.id.wv1); mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return false; } }); mWebView.loadUrl(mUrl); 

    PopupWindow代码:

     @Override public void onWindowFocusChanged(boolean hasFocus) { try { int[] location = new int[2]; (xml item where you want it to appear).getLocationOnScreen(location); //Get x and y positions p = new Point(); px = location[0]; py = location[1]; } catch (Exception e) { e.printStackTrace(); } } private void popTab(final Activity myActivity) { popupWidth = 350; popupHeight = 600; popup.setWidth(popupWidth); popup.setHeight(popupHeight); // Inflate the popup_layout.xml LinearLayout viewGroup = (LinearLayout) myActivity.findViewById(R.id.myMainLayoutID); LayoutInflater layoutInflater = (LayoutInflater) myActivity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layoutTab = layoutInflater.inflate(R.layout.mylayout, viewGroup); //Get webview from xml WebView wv = (WebView)layoutTab.findViewById(R.id.webView2); // Creating the PopupWindow final PopupWindow popup = new PopupWindow(layoutTab); //Set to view popup.setContentView(layoutTab); //Setup webview wv.loadUrl("http:www.google.com"); wv.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); //Add some animation from style folder popup.update(); popup.setAnimationStyle(R.style.Animation); popup.setFocusable(true); popup.showAtLocation(layoutTab, Gravity.NO_GRAVITY, px, py); } 

    在任何你喜欢的地方使用popTab()。 希望这有助于popup窗口。

    以上就是android开发分享android:webview里面的对话框或popup相关内容,想了解更多android开发(异常处理)及android游戏开发关注(XD中文网www.xdcnz.com)。

        本文链接:https://xdcnz.com/6259.html