本文整理汇总了C#中WebView.LoadUrl方法的典型用法代码示例。如果您正苦于以下问题:C# WebView.LoadUrl方法的具体用法?C# WebView.LoadUrl怎么用?C# WebView.LoadUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebView
的用法示例。
在下文中一共展示了WebView.LoadUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.WebViewInterop);
wv = FindViewById<WebView>(Resource.Id.Web);
wv.Settings.JavaScriptEnabled = true;
// wire up the c#-to-javascript button
RunScriptButton = FindViewById<Button>(Resource.Id.RunScriptButton);
RunScriptButton.Click += (s, e) => {
wv.LoadUrl("javascript:RunAction();");
wv.LoadUrl("javascript:SetContent('Yay for content from C#');");
};
wv.LoadUrl("file:///android_asset/Content/InteractivePages/Home.html");
wv.SetWebViewClient(new MonkeyWebViewClient(this));
wv.SetWebChromeClient(new MonkeyWebChromeClient()); // required for javascript:alert() handling
// allow zooming/panning
wv.Settings.BuiltInZoomControls = true;
wv.Settings.SetSupportZoom(true);
// we DON'T want the page zoomed-out, since it is phone-sized content
wv.Settings.LoadWithOverviewMode = false;
wv.Settings.UseWideViewPort = false;
// scrollbar stuff
wv.ScrollBarStyle = ScrollbarStyles.OutsideOverlay; // so there's no 'white line'
wv.ScrollbarFadingEnabled = false;
}
示例2: OnCreateView
public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
ViewGroup root = (ViewGroup)inflater.Inflate (Resource.Layout.fragment_webview_with_spinner, null);
// For some reason, if we omit this, NoSaveStateFrameLayout thinks we are
// FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity.
root.LayoutParameters = new ViewGroup.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent);
loadingSpinner = root.FindViewById (Resource.Id.loading_spinner);
webView = root.FindViewById<WebView> (Resource.Id.webview);
webView.SetWebChromeClient (webChromeClient);
webView.SetWebViewClient (webViewClient);
webView.Post (() => {
if (CLEAR_CACHE_ON_LOAD) {
webView.ClearCache (true);
}
webView.Settings.JavaScriptEnabled = true;
webView.Settings.JavaScriptCanOpenWindowsAutomatically = false;
webView.LoadUrl (MAP_URL);
webView.AddJavascriptInterface (new MyMapJsi (Activity, savedInstanceState), MAP_JSI_NAME);
});
return root;
}
示例3: OnCreateView
public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View v = inflater.Inflate (Resource.Layout.WebViewDialog, container, false);
txtTitle = v.FindViewById<TextView> (Resource.Id.txt_dialog_title);
divider = v.FindViewById<View> (Resource.Id.title_divider);
webView = v.FindViewById<WebView> (Resource.Id.dialog_web_view);
if (title == null || title.Length < 1) {
txtTitle.Visibility = divider.Visibility = ViewStates.Gone;
} else {
txtTitle.Text = title;
}
if (url != null && url.Length > 0) {
webView.LoadUrl (url);
}
if (showOkay) {
btnOk.Visibility = ViewStates.Visible;
btnOk.Click += (object sender, EventArgs e) => {
this.Dismiss ();
};
}
return v;
}
示例4: OnViewModelSet
protected override void OnViewModelSet()
{
Window.RequestFeature(WindowFeatures.Progress);
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
SupportActionBar.SetHomeButtonEnabled(true);
SupportActionBar.SetBackgroundDrawable(Resources.GetDrawable(Resource.Color.s_main_green));
SupportActionBar.SetLogo(Resource.Drawable.logo_white);
base.OnViewModelSet();
SetContentView(Resource.Layout.page_webview);
var set = this.CreateBindingSet<GenericWebViewView, GenericWebViewViewModel>();
set.Bind(SupportActionBar).For(v => v.Title).To(vm => vm.Title).Mode(MvxBindingMode.OneWay);
set.Apply();
_webView = FindViewById<WebView>(Resource.Id.webView);
_webView.Settings.JavaScriptEnabled = true;
_webView.Settings.SetSupportZoom(true);
var progressBar = FindViewById<ProgressBar>(Resource.Id.progressBar);
var webChromeClient = new ProgressUpdatingWebChromeClient(progressBar);
var webViewClient = new ProgressHandlingWebViewClient(progressBar);
_webView.SetWebViewClient(webViewClient);
_webView.SetWebChromeClient(webChromeClient);
_webView.LoadUrl(ViewModel.Uri);
}
示例5: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
var downloadButton = FindViewById<Button>(Resource.Id.downloadButton);
FindViewById<Button>(Resource.Id.backButton).Click += (sender, args) => { if (_webView.CanGoBack()) _webView.GoBack(); };
FindViewById<Button>(Resource.Id.forwardButton).Click += (sender, args) => { if (_webView.CanGoForward()) _webView.GoForward(); };
_webView = FindViewById<WebView>(Resource.Id.webView1);
var progressBar = FindViewById<ProgressBar>(Resource.Id.progressBar1);
var title = FindViewById<TextView>(Resource.Id.textView1);
var frame = FindViewById(Resource.Id.frameDownload);
frame.Visibility = ViewStates.Gone;
var viewControls = new ViewControls {
DownloadButton = downloadButton,
ProgressBar = progressBar,
Title = title,
DownloadFrame = frame,
Activity = this
};
_webView.Settings.JavaScriptEnabled = true;
_webView.SetWebViewClient(new YoutubeWebViewClient(viewControls));
_webView.LoadUrl("http://www.youtube.com/");
}
示例6: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
_pdfPath = _documentsPath + "/PDFView";
_pdfFilePath = Path.Combine(_pdfPath, _pdfFileName);
// Check if the PDFDirectory Exists
if(!Directory.Exists(_pdfPath)){
Directory.CreateDirectory(_pdfPath);
}
else{
// Check if the IDCard is there, If Yes Delete It. Because we will download the fresh one just in a moment
if (File.Exists(_pdfFilePath)){
File.Delete(_pdfFilePath);
}
}
_webView = FindViewById<WebView> (Resource.Id.webView1);
var settings = _webView.Settings;
settings.JavaScriptEnabled = true;
settings.AllowFileAccessFromFileURLs = true;
settings.AllowUniversalAccessFromFileURLs = true;
settings.BuiltInZoomControls = true;
_webView.SetWebChromeClient(new WebChromeClient());
_webView.LoadUrl("file:///android_asset/PDFViewer/index.html?file=" + _pdfFilePath);
}
示例7: OnCreateView
public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
var root = inflater.Inflate (Resource.Layout.fragment_webview_with_spinner, null);
// For some reason, if we omit this, NoSaveStateFrameLayout thinks we are
// FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity.
root.LayoutParameters = new ViewGroup.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent);
loading_spinner = root.FindViewById<View> (Resource.Id.loading_spinner);
web_view = root.FindViewById<WebView> (Resource.Id.webview);
web_view.SetWebViewClient (new TagWebViewClient (Activity));
web_view.Post (() => {
web_view.Settings.JavaScriptEnabled = true;
web_view.Settings.JavaScriptCanOpenWindowsAutomatically = false;
try {
var url = "http://twitter.com/#!/search/{0}";
url = string.Format (url, Uri.EscapeDataString (search_string));
web_view.LoadUrl (url);
} catch (UnsupportedEncodingException ex) {
Log.Error ("MonoIO", "Could not construct the realtime search URL", ex);
}
});
return root;
}
示例8: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
_messageHub = Mvx.Resolve<IMvxMessenger>();
var url = Intent.GetStringExtra("cheesebaron.mvxplugins.azureaccesscontrol.droid.Url");
Window.RequestFeature(WindowFeatures.Progress);
_webView = new WebView(this)
{
VerticalScrollBarEnabled = true,
HorizontalScrollBarEnabled = true,
ScrollBarStyle = ScrollbarStyles.OutsideOverlay,
ScrollbarFadingEnabled = true
};
_webView.Settings.JavaScriptEnabled = true;
_webView.Settings.SetSupportZoom(true);
_webView.Settings.BuiltInZoomControls = true;
_webView.Settings.LoadWithOverviewMode = true; //Load 100% zoomed out
var notify = new AccessControlJavascriptNotify();
notify.GotSecurityTokenResponse += GotSecurityTokenResponse;
_webView.AddJavascriptInterface(notify, "external");
_webView.SetWebViewClient(new AuthWebViewClient());
_webView.SetWebChromeClient(new AuthWebChromeClient(this));
_webView.LoadUrl(url);
AddContentView(_webView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));
}
示例9: ShouldOverrideUrlLoading
public override bool ShouldOverrideUrlLoading(WebView webView, string url)
{
// If the URL is not our own custom scheme, just let the webView load the URL as usual
var scheme = "hybrid:";
if (!url.StartsWith(scheme))
return false;
// This handler will treat everything between the protocol and "?"
// as the method name. The querystring has all of the parameters.
var resources = url.Substring(scheme.Length).Split('?');
var method = resources[0];
var parameters = System.Web.HttpUtility.ParseQueryString(resources[1]);
if (method == "UpdateLabel")
{
var textbox = parameters["textbox"];
// Add some text to our string here so that we know something
// happened on the native part of the round trip.
var prepended = string.Format("C# says \"{0}\"", textbox);
// Build some javascript using the C#-modified result
var js = string.Format("SetLabelText('{0}');", prepended);
webView.LoadUrl("javascript:" + js);
}
return true;
}
示例10: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
fb = new FacebookClient ();
appId = Intent.GetStringExtra ("AppId");
extendedPermissions = Intent.GetStringExtra ("ExtendedPermissions");
url = GetFacebookLoginUrl (appId, extendedPermissions);
WebView webView = new WebView(this);
webView.Settings.JavaScriptEnabled = true;
webView.Settings.SetSupportZoom(true);
webView.Settings.BuiltInZoomControls = true;
webView.Settings.LoadWithOverviewMode = true; //Load 100% zoomed out
webView.ScrollBarStyle = ScrollbarStyles.OutsideOverlay;
webView.ScrollbarFadingEnabled = true;
webView.VerticalScrollBarEnabled = true;
webView.HorizontalScrollBarEnabled = true;
webView.SetWebViewClient(new FBWebClient (this));
webView.SetWebChromeClient(new FBWebChromeClient (this));
AddContentView(webView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));
webView.LoadUrl(url);
}
示例11: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var url = Intent.GetStringExtra("monodroid.watoolkit.library.login.url");
System.Diagnostics.Debug.WriteLine(url);
Window.RequestFeature(WindowFeatures.Progress);
var webView = new WebView(this);
webView.Settings.JavaScriptEnabled = true;
webView.Settings.SetSupportZoom(true);
webView.Settings.BuiltInZoomControls = true;
webView.Settings.LoadWithOverviewMode = true; //Load 100% zoomed out
webView.ScrollBarStyle = ScrollbarStyles.OutsideOverlay;
webView.ScrollbarFadingEnabled = true;
webView.VerticalScrollBarEnabled = true;
webView.HorizontalScrollBarEnabled = true;
var notify = new AccessControlJavascriptNotify();
notify.GotSecurityTokenResponse += GotSecurityTokenResponse;
webView.AddJavascriptInterface(notify, "external");
webView.SetWebViewClient(new AuthWebViewClient());
webView.SetWebChromeClient(new AuthWebChromeClient(this));
webView.LoadUrl(url);
AddContentView(webView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));
}
示例12: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
//"a16fe3fa136e7b54b24664bb2a3c647e"
ColorDrawable colorDrawable = new ColorDrawable (Color.ParseColor (Helpers.ColorHeader));
ActionBar.SetBackgroundDrawable (colorDrawable);
//fb = new FacebookClient ();
appId = Intent.GetStringExtra ("AppId");
extendedPermissions = Intent.GetStringExtra ("ExtendedPermissions");
url = GetFacebookLoginUrl (appId, extendedPermissions);
WebView webView = new WebView(this);
webView.Settings.JavaScriptEnabled = true;
webView.Settings.SetSupportZoom(true);
webView.Settings.BuiltInZoomControls = true;
webView.Settings.LoadWithOverviewMode = true; //Load 100% zoomed out
webView.ScrollBarStyle = ScrollbarStyles.OutsideOverlay;
webView.ScrollbarFadingEnabled = true;
webView.VerticalScrollBarEnabled = true;
webView.HorizontalScrollBarEnabled = true;
webView.SetWebViewClient(new FBWebClient (this));
webView.SetWebChromeClient(new FBWebChromeClient (this));
AddContentView(webView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));
webView.LoadUrl(url);
}
示例13: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
//web_view.SetLayerType(View.LAYER_TYPE_HARDWARE, null);
//web_view.getSettings().setRenderPriority(RenderPriority.HIGH);
//web_view.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
// web_view.Settings.SetAppCacheEnabled (false);
web_view = FindViewById<WebView> (Resource.Id.webview);
web_view.Settings.JavaScriptEnabled = true;
web_view.LoadUrl ("http://google.com");
//WebSettings.RenderPriority.High
// Set our view from the "main" layout resource
// SetContentView (Resource.Layout.Main);
//
// // Get our button from the layout resource,
// // and attach an event to it
// Button button = FindViewById<Button> (Resource.Id.myButton);
//
// button.Click += delegate {
// button.Text = string.Format ("{0} clicks!", count++);
//};
}
示例14: OnOptionsItemSelected
/// <param name="item">The menu item that was selected.</param>
/// <summary>
/// This hook is called whenever an item in your options menu is selected.
/// </summary>
/// <returns>To be added.</returns>
public override bool OnOptionsItemSelected(IMenuItem item)
{
base.OnOptionsItemSelected(item);
var web = new WebView(this);
switch (item.ItemId)
{
case Resource.Id.SearchByBook:
{
var Bookintent = new Intent(this, typeof(SearchByBook));
StartActivity(Bookintent);
break;
}
case Resource.Id.SearchByAuthor:
{
var Authorintent = new Intent(this, typeof(SearchByAuthor));
StartActivity(Authorintent);
break;
}
case Resource.Id.ShowBySubject:
{
var intentSubject = new Intent(this, typeof(HadithSubject));
StartActivity(intentSubject);
break;
}
case Resource.Id.ShowByTitle:
{
var intentTitle = new Intent(this, typeof(HadithTitle));
StartActivity(intentTitle);
break;
}
case Resource.Id.help:
web.LoadUrl("http://www.softlock.net/");
break;
case Resource.Id.about:
web.LoadUrl("http://www.softlock.net/");
break;
default:
break;
}
return true;
}
示例15: ShouldOverrideUrlLoading
public override bool ShouldOverrideUrlLoading (WebView view, string url)
{
WebHybrid hybrid;
if (!this.webHybrid.TryGetTarget(out hybrid) || !hybrid.CheckRequest(url))
{
view.LoadUrl(url);
}
return true;
}