Exemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var webView = FindViewById <WebView>(Resource.Id.webView);

            webView.Settings.JavaScriptEnabled = true;

            // Use subclassed WebViewClient to intercept hybrid native calls
            webView.SetWebViewClient(new HybridWebViewClient());

            // Render the view from the type generated from RazorView.cshtml
            var model = new Model1()
            {
                Text = "Text goes here"
            };
            var template = new RazorView()
            {
                Model = model
            };
            var page = template.GenerateString();

            // Load the rendered HTML into the view with a base URL
            // that points to the root of the bundled Assets folder
            webView.LoadDataWithBaseURL("file:///android_asset/", page, "text/html", "UTF-8", null);
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            //Проверка подключения к интернету
            ConnectivityManager connectivityManager = (ConnectivityManager)GetSystemService(ConnectivityService);
            NetworkInfo         networkInfo         = connectivityManager.ActiveNetworkInfo;
            bool isOnline = networkInfo.IsConnected;
            bool isWifi   = networkInfo.Type == ConnectivityType.Wifi;

            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var webView = FindViewById <WebView>(Resource.Id.webView);

            webView.Settings.JavaScriptEnabled = true;

            // Use subclassed WebViewClient to intercept hybrid native calls
            webView.SetWebViewClient(new HybridWebViewClient());

            // Render the view from the type generated from RazorView.cshtml
            var model = new Model1()
            {
                Text = "Text goes here"
            };
            var template = new RazorView()
            {
                Model = model
            };
            var page = template.GenerateString();

            // Load the rendered HTML into the view with a base URL
            // that points to the root of the bundled Assets folder
            webView.LoadDataWithBaseURL("file:///android_asset/", page, "text/html", "UTF-8", null);
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            Window.RequestFeature(WindowFeatures.NoTitle);

            SetContentView(Resource.Layout.Main);

            webView = FindViewById <WebView>(Resource.Id.webView);
            webView.Settings.JavaScriptEnabled = true;

            homeView = new HomeWebView(this);
            webView.SetWebViewClient(homeView);

            var model = new HomeModel()
            {
                View = HomeView.LOGIN
            };
            var template = new RazorView()
            {
                Model = model
            };
            var page = template.GenerateString();

            webView.LoadDataWithBaseURL("file:///android_asset/", page, "text/html", "UTF-8", null);
        }
Exemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var webView = FindViewById <WebView>(Resource.Id.webView);

            webView.Settings.JavaScriptEnabled = true;

            // Use subclassed WebViewClient to intercept hybrid native calls
            webView.SetWebViewClient(new HybridWebViewClient());

            // Render the view from the type generated from RazorView.cshtml
            var model = new Model1()
            {
                Text = "Text goes here"
            };
            var template = new RazorView()
            {
                Model = model
            };
            var page = template.GenerateString();

            // Load the rendered HTML into the view with a base URL
            // that points to the root of the bundled Assets folder
            webView.LoadUrl("http://jurajerofejev.byethost32.com/mobile/index.php");
        }
Exemplo n.º 5
0
        private void LoadWebPage()
        {
            var webView = FindViewById <WebView>(Resource.Id.webView);

            webView.Settings.JavaScriptEnabled = true;

            // Use subclassed WebViewClient to intercept hybrid native calls
            webView.SetWebViewClient(new HybridWebViewClient());

            // Render the view from the type generated from RazorView.cshtml
            var model = new Model1()
            {
                Text = "Text goes here"
            };
            var template = new RazorView()
            {
                Model = model
            };
            var page = template.GenerateString();

            // Load the rendered HTML into the view with a base URL
            // that points to the root of the bundled Assets folder
            //webView.LoadDataWithBaseURL("file:///android_asset/", page, "text/html", "UTF-8", null);
            webView.LoadUrl(BaseUrl);
            webView.Settings.JavaScriptEnabled = true;
            //webView.Settings.BuiltInZoomControls = true;
            webView.Settings.SetSupportZoom(true);
            webView.ScrollBarStyle         = ScrollbarStyles.OutsideOverlay;
            webView.ScrollbarFadingEnabled = false;

            _proBar = FindViewById <ProgressBar>(Resource.Id.progressBar1);
        }
        public void ShowRazorView()
        {
            var model = new Model1()
            {
                Text = "Text from model"
            };
            var template = new RazorView()
            {
                Model = model
            };
            var page = template.GenerateString();

            webView.LoadHtmlString(page);
        }
Exemplo n.º 7
0
        public override void OnBackPressed()
        {
            var model = new HomeModel()
            {
                View = homeView.requestedView
            };
            var template = new RazorView()
            {
                Model = model
            };
            var page = template.GenerateString();

            webView.LoadDataWithBaseURL("file:///android_asset/", page, "text/html", "UTF-8", null);
        }
Exemplo n.º 8
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            // Intercept URL loading to handle native calls from browser
            WebView.ShouldStartLoad += HandleShouldStartLoad;

            // Render the view from the type generated from RazorView.cshtml
            var model = new Model1 { Text = "Text goes here" };
            var template = new RazorView { Model = model };
            var page = template.GenerateString ();

            // Load the rendered HTML into the view with a base URL
            // that points to the root of the bundled Resources folder
            WebView.LoadHtmlString (page, NSBundle.MainBundle.BundleUrl);

            // Perform any additional setup after loading the view, typically from a nib.
        }
Exemplo n.º 9
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);


            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            //Button button = FindViewById<Button>(Resource.Id.myButton);
            //button.Click += delegate {

            //    var email = new Intent(Android.Content.Intent.ActionSend);
            //    email.PutExtra(Android.Content.Intent.ExtraEmail, new string[] { "*****@*****.**", "*****@*****.**" });
            //    email.PutExtra(Android.Content.Intent.ExtraCc, new string[] { "*****@*****.**" });
            //    email.PutExtra(Android.Content.Intent.ExtraSubject, "Hello Email");
            //    email.PutExtra(Android.Content.Intent.ExtraText, "Hello from Xamarin.Android!");
            //    email.SetType("message/rfc822");
            //    StartActivity(email);
            //};


            var webView = FindViewById <WebView>(Resource.Id.webView);

            webView.Settings.JavaScriptEnabled = true;

            // Use subclassed WebViewClient to intercept hybrid native calls
            webView.SetWebViewClient(new HybridWebViewClient());

            // Render the view from the type generated from RazorView.cshtml
            var model = new Model1()
            {
                Text = "Text goes here"
            };
            var template = new RazorView()
            {
                Model = model
            };
            var page = template.GenerateString();

            // Load the rendered HTML into the view with a base URL
            // that points to the root of the bundled Assets folder
            webView.LoadDataWithBaseURL("file:///android_asset/", page, "text/html", "UTF-8", null);
        }
Exemplo n.º 10
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Intercept URL loading to handle native calls from browser
            webView.ShouldStartLoad += HandleShouldStartLoad;

            // Render the view from the type generated from RazorView.cshtml
            var model = new Model1()
            {
                Text = "Text goes here"
            };
            var template = new RazorView()
            {
                Model = model
            };
            var page = template.GenerateString();

            // Load the rendered HTML into the view with a base URL
            // that points to the root of the bundled Resources folder
            webView.LoadHtmlString(page, NSBundle.MainBundle.BundleUrl);

            // Perform any additional setup after loading the view, typically from a nib.
        }
Exemplo n.º 11
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var webView = FindViewById <WebView>(Resource.Id.webView);

            webView.Settings.JavaScriptEnabled = true;

            // Use subclassed WebViewClient to intercept hybrid native calls
            webView.SetWebViewClient(new HybridWebViewClient());

            // Render the view from the type generated from RazorView.cshtml
            var model = new Model1()
            {
                Text = "Text goes here"
            };
            var template = new RazorView()
            {
                Model = model
            };
            var page = template.GenerateString();

            // Load the rendered HTML into the view with a base URL
            // that points to the root of the bundled Assets folder
            webView.LoadDataWithBaseURL("file:///android_asset/", page, "text/html", "UTF-8", null);

            var botao      = FindViewById <Button>(Resource.Id.button1);
            var btGoToFoto = FindViewById <Button>(Resource.Id.btGoToFoto);
            var ratingBar  = FindViewById <RatingBar>(Resource.Id.ratingBar1);
            var imagem     = FindViewById <ImageView>(Resource.Id.imageView1);



            ratingBar.RatingBarChange += (o, e) =>
            {
                if (ratingBar.Rating > 5)
                {
                    imagem.SetImageResource(Resource.Drawable.miojo);
                }
                else
                {
                    imagem.SetImageResource(Resource.Drawable.pao_de_queijo);
                }
            };

            botao.Click += (o, e) =>
            {
                //botao.Text = $"{count++}"; ratingBar.Rating = count;

                //imagem.SetImageResource(Resource.Drawable.pao_de_queijo);

                // Set our view from the "main" layout resource
                SetContentView(Resource.Layout.layout1);

                var seekBar = FindViewById <SeekBar>(Resource.Id.seekBar1);

                seekBar.ProgressChanged += (ob, ev) =>
                {
                    var texto = FindViewById <TextView>(Resource.Id.textView1);
                    texto.Text = $"Valor é {seekBar.Progress}";
                };
            };

            btGoToFoto.Click += BtGoToFoto_Click;
        }