3

Here is xml code of main activity..

     <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>

I am adding my webview in Framelayout. (I am using addView method for adding my webView). Loading webView with loadUrl method. From that page, I clicked on one link and its opening it inside an app which is fine for me. But when I click on Back button, my webview reloads. I don't want my webview to relaod if user goes back.

Ronak
  • 165
  • 1
  • 3
  • 15

1 Answers1

0

try this one..

@override
public void onBackPressed(){
 super.onBackPressed();
 if ( webview.canGoBack()) {
 webview.goBack();            
   }
}
Sunil Kumar
  • 7,086
  • 4
  • 32
  • 50
  • I did the same thing. Its going back but previous page is loading again. I don't want my previous pages to reload when user goes back. – Ronak Sep 18 '13 at 18:12