Hi, How can I error trapping on WebView. I want to redirect to another page if url not found
<Button
android:id="@+id/Button4"
android:layout_width="380.5dp"
android:layout_height="1.0dp"
android:background="#fa3e3e"
android:textSize="11dp"
android:layout_marginRight="295.5dp"
android:visibility="invisible"
android:text="Load" />
<AbsoluteLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView" />
</AbsoluteLayout>
click event on button4 will load the page:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
mWebClient = new WebClient();
mWebView = FindViewById<WebView>(Resource.Id.webView);
mButton4 = FindViewById<Button>(Resource.Id.button4);
mButton4.Click += mButton4_Click;
void mButton4_Click(object sender, EventArgs e)
{
mWebClient.ShouldOverrideUrlLoading(mWebView,"http://something.com");
}
}
public class WebClient : WebViewClient
{
public override bool ShouldOverrideUrlLoading(WebView view, string url)
{
view.LoadUrl(url);
return true;
}
}
Any help? Thank you
<Button
android:id="@+id/Button4"
android:layout_width="380.5dp"
android:layout_height="1.0dp"
android:background="#fa3e3e"
android:textSize="11dp"
android:layout_marginRight="295.5dp"
android:visibility="invisible"
android:text="Load" />
<AbsoluteLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView" />
</AbsoluteLayout>
click event on button4 will load the page:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
mWebClient = new WebClient();
mWebView = FindViewById<WebView>(Resource.Id.webView);
mButton4 = FindViewById<Button>(Resource.Id.button4);
mButton4.Click += mButton4_Click;
void mButton4_Click(object sender, EventArgs e)
{
mWebClient.ShouldOverrideUrlLoading(mWebView,"http://something.com");
}
}
public class WebClient : WebViewClient
{
public override bool ShouldOverrideUrlLoading(WebView view, string url)
{
view.LoadUrl(url);
return true;
}
}
Any help? Thank you