2016-04-25 91 views
0

我創建了一個webview,其中如果單擊一個外部鏈接,它將轉到另一個帶有加載的外部鏈接的webview。我希望它能夠返回到它所導航的頁面,如果我的後退按鈕被點擊的話。例如,如果我從主webview的第4頁導航到某個外部鏈接webview,並且如果我點擊返回它應該返回到第4頁而不是第1頁。這是我的XML頁面供參考。從一個webview導航到另一個

<WebView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/activity_main_webview"/> 
<WebView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="45dp" 
    android:id="@+id/external_webview"> 
</WebView> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:id="@+id/ext_link" 
    android:layout_height="fill_parent"> 
    <RelativeLayout android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:background="#FFFFFF" 
     android:layout_height="45dp" 
     android:weightSum="1"> 
     <Button 
      android:id="@+id/backtonews" 
      android:layout_marginTop="7dp" 
      android:layout_width="190dp" 
      android:layout_height="30dp" 
      android:background="@drawable/button"> 
     </Button> 
     <Button 
      android:id="@+id/refresh" 
      android:layout_marginTop="7dp" 
      android:layout_width="30dp" 
      android:layout_height="30dp" 
      android:background="@drawable/refresh" 
      android:layout_alignParentRight="true" 
      android:singleLine="false"> 
     </Button> 

</RelativeLayout> 

回答

1

你必須保存你在第一個Web視圖,在出發前二日一則聽返回鍵,然後彈出的第一個網站查看了保存地址

讓我知道最後一頁如果你想要更多的細節。

+0

我無法爲它寫回功能。你能告訴我如何去做的細節。 '' //做你的工作here' ; '@ Override' '公共無效onBackPressed(){'' super.onBackPressed(): –

+0

你當返回鍵通過重寫onBackPressed方法壓制始終可以做到的手動操作'}' –

+0

我可以編寫正常的後臺功能,但我想知道如何存儲我們在代碼爲 –

相關問題