Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to start an Activity within a WebViewClient class?

$
0
0

I want to show a progress bar when the webview is loading.

I have a LinearLayout axml file which has a nested ProgressBar.

Im stuck on how to start the ProgressBar activity?
In the Activity class, the 'onCreate' method does not get called?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/linearLayout1">
    <ProgressBar
        android:id="@+id/progressBar2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="@android:style/Widget.ProgressBar.Small"
        android:layout_marginRight="5dp" />
</LinearLayout>

Within my webview custom renderer class, I use the WebViewClient class.

        public class MyWebViewClient : WebViewClient
        {
            public override void OnPageStarted(Android.Webkit.WebView view, string url, Android.Graphics.Bitmap favicon)
            {
                base.OnPageStarted(view, url, favicon);

        // How to write code to start the Progress Bar activity??????
        }
    }

Here is my Activity Class:

        [Activity]
        public class ProgressBarActivity : Android.App.Activity
        {
            protected override void OnCreate(Bundle savedInstanceState)
            {
                base.OnCreate(savedInstanceState);

                // Defines your UI
                SetContentView(ResearchMobile.Droid.Resource.Id.linearLayout1);
            }

            public Android.Views.View startProgresBar()
            {
                // Retrieve the widdget
                //Xamarin.Forms.ProgressBar progressBar = (ProgressBar)FindViewById(ResearchMobile.Droid.Resource.Id.progressBar2);
                Android.Views.View progressBar = FindViewById(ResearchMobile.Droid.Resource.Id.progressBar2);

                return progressBar;
            }
        }

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>