Introduction
The Progress dialog showing a progress indicator it showing text message or view. It’s using at the same time text message or a view only. More details Click.
Let’s start,
Step 1: Open Visual Studio->New Project->Templates->Visual C#->Android->Blank App.
Select Blank App. Then give Project Name and Project Location.
Step 2: Next to Open Solution Explorer-> Project Name->MainActivity.cs. open C# code then give following code. Here already created default template in Button click event. Then that event to create ProgressDialog Functions.
C# Code
- using System;
- using Android.App;
- using Android.Content;
- using Android.Runtime;
- using Android.Views;
- using Android.Widget;
- using Android.OS;
- namespace ProgressDialog
- {
- [Activity(Label = "ProgressDialog", MainLauncher = true, Icon = "@drawable/icon")]
- public class MainActivity: Activity
- {
- Android.App.ProgressDialog progress;
- protected override void OnCreate(Bundle bundle)
- {
- base.OnCreate(bundle);
-
- SetContentView(Resource.Layout.Main);
-
-
- Button button = FindViewById < Button > (Resource.Id.MyButton);
- button.Click += delegate
- {
- progress = new Android.App.ProgressDialog(this);
- progress.Indeterminate = true;
- progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
- progress.SetMessage("Loading... Please wait...");
- progress.SetCancelable(false);
- progress.Show();
- };
- }
- }
- }
Step 3: Press F5 or Build and Run the Application.
Finally, successfully created Xamarin Android ProgressDialog Application.