Skip to content
Branch: master
Find file History
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
Assets
Images reorganizing files into recipes folder Mar 7, 2018
Properties
Resources reorganizing files into recipes folder Mar 7, 2018
Activity1.cs reorganizing files into recipes folder Mar 7, 2018
LoadWebPage.csproj reorganizing files into recipes folder Mar 7, 2018
LoadWebPage.sln reorganizing files into recipes folder Mar 7, 2018
README.md

README.md

id title brief article sdk
7836FE10-1097-FAA8-898E-AE4853E48FE8
Load a Web Page
This recipe shows how to load a web page in a WebView.

Recipe

  • Create a layout file that contains a WebView, such as Main.axml in the example code:
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:id="@+id/LocalWebView">
</WebView>
  • Use the Main.axml as the view for your activity and assign the WebView to a local variable.
SetContentView (Resource.Layout.Main);

WebView localWebView = FindViewById<WebView>(Resource.Id.LocalWebView);
webView.SetWebViewClient (new WebViewClient ()); // stops request going to Web Browser
localWebView.LoadUrl("http://developer.xamarin.com");

If the website you are navigating to requires Javascript, enable it via the Settings.JavaScriptEnabled property:

webView.Settings.JavaScriptEnabled = true;
webView.LoadUrl("http://youtube.com");
You can’t perform that action at this time.