【问题标题】:WebView goback() reloads last pageWebView goback() 重新加载最后一页
【发布时间】:2013-09-23 14:55:09
【问题描述】:

这是主要活动的xml代码..

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/relativeMain"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context=".MainActivity" >

        <FrameLayout android:id="@+id/rightMainContent"
            android:background="#ffffff" 
            android:layout_width="match_parent"
            android:layout_height="match_parent"
        >
        </FrameLayout>

        <RelativeLayout android:id="@+id/rel_overlay"
                        android:background="@color/whiteColor"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" >

                <TextView
                    android:id="@+id/txtOverlay"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_toRightOf="@+id/progressOverlay"
                    android:textSize="15sp"
                    android:text="@string/loading" />

                <ProgressBar
                    android:id="@+id/progressOverlay"
                    style="@android:style/Widget.ProgressBar"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="7dp"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="95dp"
                     />
        </RelativeLayout>
    </RelativeLayout>

我在 Framelayout 中添加我的 webview。 (我正在使用 addView 方法添加我的 webView)。使用 loadUrl 方法加载 webView。从那个页面,我点击了一个链接,然后在一个对我来说很好的应用程序中打开它。但是当我点击后退按钮时,我的 webview 会重新加载。如果用户返回,我不希望我的 webview 重新加载。

【问题讨论】:

    标签: android webview reload webviewclient


    【解决方案1】:

    试试这个..

    @override
    public void onBackPressed(){
     super.onBackPressed();
     if ( webview.canGoBack()) {
     webview.goBack();            
       }
    }
    

    【讨论】:

    • 我也做了同样的事情。它返回,但上一页再次加载。当用户返回时,我不希望我以前的页面重新加载。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-31
    • 1970-01-01
    • 2014-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多