loginButton.click += delegate
{
ProgressDialog progress = new ProgressDialog(Application.Context,
Resource.Style.CustomAlertDialogStyle);
progress.SetMessage(" Please wait...");
progress.SetIcon(Resource.Drawable.next);
progress.SetCancelable(false);
progress.SetProgressStyle(ProgressDialogStyle.Spinner);
progress.SetInverseBackgroundForced(true);
progress.Indeterminate = true;
progress.SetIndeterminateDrawable(GetDrawable(Resource.Drawable.Header));
progress.Show();
}
Here is my code for the Progress dialog, What I want is that the dialog appears when I log in as I have to call a lot of data from service side and it works properly in higher android version but the problem is when I use it on a device with Android version KitKat or below the Application crashes when the compiler reaches progress.show(); and I'm unable to understand why as I am new to Xamarin Android.
i found the answer myself by doing the things below
ProgressDialog dialog;
loginButton.Click += async delegate
{
dialog = ProgressDialog.Show(this, string.Empty, string.Empty);
dialog.SetContentView(Resource.Layout.Loader);
.
.
.
}
loader.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#105499"
android:orientation="vertical"
>
<ProgressBar
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical|center_horizontal"
android:background="@android:color/transparent"
android:indeterminateDrawable="@drawable/loader_Anime"
android:layout_marginBottom="20dp"/>
</LinearLayout>
Loader_anime.xml
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/Oxy_top"
android:duration="50"/>
<item
android:drawable="@drawable/Oxy_right"
android:duration="50"/>
<item
android:drawable="@drawable/Oxy_bottom"
android:duration="50"/>
<item
android:drawable="@drawable/Oxy_left"
android:duration="50"/>
</animation-list>