protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.View_Post); var toolbar = FindViewById <Toolbar> (Resource.Id.toolbar); SetSupportActionBar(toolbar); var actionBar = SupportActionBar; if (actionBar != null) { actionBar.SetDisplayHomeAsUpEnabled(true); } webView = FindViewById <WebView> (Resource.Id.webView); webView.Settings.JavaScriptEnabled = true; var webClient = new WebChromeClient(); webView.SetWebChromeClient(webClient); webView.LoadUrl(ViewModel.Link); }
public override void SetWebChromeClient(WebChromeClient client) { if (client.GetType() == typeof(MyWebChromeClient)) { MyWebChromeClient = client as MyWebChromeClient; } base.SetWebChromeClient(client); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); WebView web = FindViewById <WebView> (Resource.Id.threatView); web.Settings.JavaScriptEnabled = true; var client = new WebChromeClient(); web.SetWebChromeClient(client); // Load page in WebView web.LoadUrl("file:///android_asset/ThreatView.html"); // Start main detection process var manager = ApplicationContext.PackageManager; var timer = new System.Timers.Timer(1000); timer.Elapsed += (sender, e) => { List <Connection> connections = ConnectionController.GetConnections(manager); ThreatClassifier t = new ThreatClassifier(); t.Classify(connections); List <Organization> organizations = OrganizationController.CreateFromConnections(connections); int i = 0; foreach (Organization organization in organizations.OrderBy((o) => - o.ThreatLevel)) { if (i > 7) { break; } // Draw organisation SetLabel(i, organization.Name.Split('.').Last()); SetThreatLevel(i, Math.Min(1.0, organization.ThreatLevel / 5)); SetNumberOfConnections(i, organization.Connections.Count); i++; } // Hide the unneeded organisations SetNumberOfOrganisations(organizations.Count); }; timer.Start(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab); fab.Click += FabOnClick; var myChromeClient = new WebChromeClient(); wv.SetWebChromeClient(myChromeClient); var myWebClient = new MyWebViewClient(Assets); wv.SetWebViewClient(myWebClient); wv.Settings.JavaScriptEnabled = true; wv.Settings.DomStorageEnabled = true; wv.Settings.AllowContentAccess = true; wv.Settings.AllowFileAccess = true; wv.Settings.AllowFileAccessFromFileURLs = true; wv.CanGoBack(); wv.CanGoForward(); global::Android.Webkit.WebView.SetWebContentsDebuggingEnabled(true); if (savedInstanceState != null) { wv.RestoreState(savedInstanceState); } else { // wv.LoadDataWithBaseURL( "file:///android_asset/", new StreamReader( Assets.Open( "index2.html" ) ).ReadToEnd(), "text/html", "UTF-8", null ); wv.LoadUrl("file:///android_asset/index.html"); } }
private void Initialize() { //The topmost layout of the window where the actual VideoView will be added to mRootLayout = (FrameLayout)((Activity)this.Context).Window.DecorView; mWebSettings = this.Settings; mWebSettings.JavaScriptEnabled = true; mWebSettings.SetPluginState(WebSettings.PluginState.On); mWebSettings.UserAgentString = mWebSettings.UserAgentString + mExtraUA; if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBeanMr1) { mWebSettings.MediaPlaybackRequiresUserGesture = true; } mChromeClient = new DailyMotionWebChromeClient(this, this.Context); SetWebChromeClient(mChromeClient); SetWebViewClient(new DailyMotionWebViewClient(this)); }
public static void setWebChromeClient(this WebView webView, WebChromeClient client) { webView.SetWebChromeClient(client); }
protected virtual Com.Tencent.Smtt.Sdk.WebChromeClient GetFormsWebChromeClient() { var client = new WebChromeClient(this); return(client); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); RequestWindowFeature(WindowFeatures.NoTitle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); /**/ var j = this.Intent.GetStringExtra("ItemRow"); item = JsonConvert.DeserializeObject <Item>(j); ColorDrawable color = new ColorDrawable(Color.OrangeRed); var actionBar = FindViewById <LinearLayout>(Resource.Id.actonBar); actionBar.SetBackgroundDrawable(color); FindViewById <TextView>(Resource.Id.txtTitle).Text = item.Descrip; //back ImageButton btnBack = this.FindViewById <ImageButton>(Resource.Id.btnBack); btnBack.Click += (s1, e1) => { this.Finish(); // wv.GoBack(); }; btnBack.SetBackgroundResource(Resource.Drawable.back); //scan ImageButton btnScan = this.FindViewById <ImageButton>(Resource.Id.btnScan); btnScan.Click += (s1, e1) => { CallWebViewSendData(); }; btnScan.SetBackgroundResource(Resource.Drawable.Barcode2); Information info = new Information() { user_id = "A110018", user_name = "Roger Roan" }; String content = JsonConvert.SerializeObject(info, Formatting.None); MobileBarcodeScanner.Initialize(Application); wv = this.FindViewById <WebView>(Resource.Id.webview); refresher = FindViewById <CustomSwipeRefreshLayout>(Resource.Id.refresher); refresher.setCanChildScrollUpCallback(this); refresher.SetColorScheme(Resource.Color.xam_dark_blue, Resource.Color.xam_purple, Resource.Color.xam_gray, Resource.Color.xam_green); wv.Settings.JavaScriptEnabled = true; wv.AddJavascriptInterface(new JsInteration(this), "control"); wv.Settings.SetSupportZoom(true); wv.Settings.BuiltInZoomControls = true; wv.Settings.UseWideViewPort = true; wv.Settings.LoadWithOverviewMode = true; WebChromeClient wc = new WebChromeClient(); wv.SetWebChromeClient(wc); MyWebViewClient wvc = new MyWebViewClient(refresher); wv.SetWebViewClient(wvc); wv.LoadUrl(item.Link); refresher.Refresh += delegate { wv.Reload(); }; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment var metrics = Resources.DisplayMetrics; var view = inflater.Inflate(Resource.Layout.md_tab_Detail, container, false); name = view.FindViewById <TextView>(Resource.Id.np_name); criticRating = view.FindViewById <TextView>(Resource.Id.md_CriticRating); userRating = view.FindViewById <TextView>(Resource.Id.md_UserRating); ratingbar = view.FindViewById <RatingBar>(Resource.Id.ratingBar1); ratingImage = view.FindViewById <ImageView>(Resource.Id.imageView1); //BackgroundImage = view.FindViewById<ImageView>(Resource.Id.np_imageView); name.Text = Movie.Movie.Name; #region Display Ratings decimal cr = 0; int crCount = 0; decimal ur = 0; int urCount = 0; foreach (var rat in Movie.CriticRatings) { if (rat.Rating.HasValue) { cr += rat.Rating.Value; crCount++; } } foreach (var rat in Movie.UserRatings) { if (rat.Rating.HasValue) { ur += rat.Rating.Value; urCount++; } } if (crCount > 0) { criticRating.Text = String.Format("{0}", cr / crCount); } if (urCount > 0) { userRating.Text = String.Format("{0}", ur / urCount); } ratingbar.RatingBarChange += (o, e) => { if (ratingbar.Rating > 4) { ratingImage.SetBackgroundResource(Resource.Drawable.sm_5); } else if (ratingbar.Rating > 3) { ratingImage.SetBackgroundResource(Resource.Drawable.sm_4); } else if (ratingbar.Rating > 2) { ratingImage.SetBackgroundResource(Resource.Drawable.sm_3); } else if (ratingbar.Rating > 1) { ratingImage.SetBackgroundResource(Resource.Drawable.sm_2); } else { ratingImage.SetBackgroundResource(Resource.Drawable.sm_1); } }; #endregion //var imageBitmap = ImageHelper.DecodeByteArraytoBitmap(Movie.Movie.LargePicture); //BackgroundImage.SetImageBitmap(imageBitmap); #region Movie trailer in WebView MovieTrailer = view.FindViewById <WebView>(Resource.Id.np_videoView); int intDisplayWidth = metrics.WidthPixels + 100; int intDisplayHeight = Convert.ToInt16(metrics.WidthPixels * (10.0 / 16.0)); string html = @"<html><body><iframe width=""videoWidth"" height=""videoHeight"" src=""MovieTrailerUrl"" allowfullscreen></iframe></body></html>"; var trailerWebChromeClient = new WebChromeClient(); trailerWebChromeClient.OnShowCustomView(view, null); var settings = MovieTrailer.Settings; settings.JavaScriptEnabled = true; settings.UseWideViewPort = true; settings.LoadWithOverviewMode = true; settings.JavaScriptCanOpenWindowsAutomatically = true; settings.DomStorageEnabled = true; settings.SetRenderPriority(WebSettings.RenderPriority.High); settings.BuiltInZoomControls = false; settings.JavaScriptCanOpenWindowsAutomatically = true; MovieTrailer.SetWebChromeClient(trailerWebChromeClient); settings.AllowFileAccess = true; settings.SetPluginState(WebSettings.PluginState.On); string strYouTubeURL = html.Replace("videoWidth", intDisplayWidth.ToString()).Replace("videoHeight", intDisplayHeight.ToString()).Replace("MovieTrailerUrl", MovieTrailerUrl); MovieTrailer.LoadDataWithBaseURL(null, strYouTubeURL, "text/html", "UTF-8", null); #endregion return(view); }
private void initWebView() { //mProgressBar.setVisibility(View.VISIBLE); WebSettings ws = webView.Settings; // 网页内容的宽度是否可大于WebView控件的宽度 ws.LoadWithOverviewMode = false; // 保存表单数据 ws.SaveFormData = true; // 是否应该支持使用其屏幕缩放控件和手势缩放 ws.SetEnableSmoothTransition(true); ws.BuiltInZoomControls = true; ws.DisplayZoomControls = false; // 启动应用缓存 ws.SetAppCacheEnabled(true); // 设置缓存模式 //ws.setCacheMode(WebSettings.LOAD_DEFAULT); ws.CacheMode = CacheModes.Default; // setDefaultZoom api19被弃用 // 设置此属性,可任意比例缩放。 ws.UseWideViewPort = true; // 不缩放 webView.SetInitialScale(100); // 告诉WebView启用JavaScript执行。默认的是false。 ws.JavaScriptEnabled = true; // 页面加载好以后,再放开图片 ws.BlockNetworkImage = false; // 使用localStorage则必须打开 ws.DomStorageEnabled = true; // 排版适应屏幕 ws.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.NarrowColumns); // WebView是否新窗口打开(加了后可能打不开网页) ws.SetSupportMultipleWindows(true); // webview从5.0开始默认不允许混合模式,https中不能加载http资源,需要设置开启。 if (Build.VERSION.SdkInt >= Build.VERSION_CODES.Lollipop) { ws.MixedContentMode = WebSettings.MixedContentAlwaysAllow; } /** 设置字体默认缩放大小(改变网页字体大小,setTextSize api14被弃用)*/ ws.TextZoom = 100; mWebviewClient = new WebViewClient(); mWebChromeClient = new WebChromeClient(); webView.SetWebViewClient(mWebviewClient); // 与js交互 //webView.addJavascriptInterface(new ImageClickInterface(this), "injectedObject"); }