【问题标题】:webview reload to home page when switching between activities在活动之间切换时webview重新加载到主页
【发布时间】:2017-10-29 00:35:25
【问题描述】:

你好,我正在制作一个 vwe 浏览器应用程序,它有一个问题,不知道我发布的代码的哪一部分

  1. 当我进入书签活动时,书签活动打开正常,但是当我切换回网页视图时,它重新加载到主页,而不是它在 PS 中的最后一页,当屏幕改变方向时它不会重新加载

  2. 有点慢

  3. 打开像 youtube 这样的视频,但不要让它们全屏显示

    ourview = (WebView) findViewById(R.id.webView1); ourview.getSettings().setJavaScriptEnabled(true); ourview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); ourview.getSettings().setLoadWithOverviewMode(true); ourview.getSettings().setSupportZoom(true); ourview.getSettings().setBuiltInZoomControls(true); 我们的view.getSettings().getAllowFileAccess(); ourview.getSettings().getAllowFileAccessFromFileURLs(); ourview.getSettings().getJavaScriptCanOpenWindowsAutomatically(); ourview.getSettings().setLoadsImagesAutomatically(true); ourview.loadUrl("http://www.google.com");

【问题讨论】:

    标签: android android-studio webview


    【解决方案1】:

    在不同activity之间切换,总会调用onCreate()方法。
    因此,由于您的 ourview.loadUrl("http://www.google.com"); 在 onCreate() 方法中,
    每次在这些活动之间切换时都会调用它。
    这就是为什么 webView 在活动之间切换时会重新加载到主页的原因。

    【讨论】:

    • 那不起作用我的项目只有 2 个类,而带有 webview 的类中有 307 行,我不知道如何共享它我可以以某种方式共享我的项目吗?
    猜你喜欢
    • 2012-02-10
    • 2012-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多