goback并在webview片段中下载监听器

时间:2013-05-04 23:42:00

标签: android webview android-fragments

我有一个viewpager,它有4个webview片段。我是片段的新内容,我需要在webview中添加d​​ownloadListener和goback。这是我的webview代码。任何帮助都会很棒。我已经尝试了两天的各种东西了,

 private static final String WebSettings = null;
 private WebView webView;
 private Bundle webViewBundle;




    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.fragment_1,
        container, false);



    webView = (WebView) ll.findViewById(R.id.webview);
    webView.setWebViewClient(new WebViewClient());
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setSupportZoom(true);
    webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);   
    webView.getSettings().setAllowFileAccess(true); 
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setRenderPriority(RenderPriority.HIGH);





     if (webViewBundle == null) {
     try{
        webView.loadUrl("http://www.teamvenum.com");
     }catch (Exception e){
        e.printStackTrace();}
    } else {
        webView.restoreState(webViewBundle);
    }



    return ll;

    }






    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }



    @Override
    public void onPause() {
    super.onPause();

    webViewBundle = new Bundle();
    webView.saveState(webViewBundle);

    }

}

0 个答案:

没有答案