Xamarin Android: Create Android ProgressDialog App

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
  1. using System;  
  2. using Android.App;  
  3. using Android.Content;  
  4. using Android.Runtime;  
  5. using Android.Views;  
  6. using Android.Widget;  
  7. using Android.OS;  
  8. namespace ProgressDialog  
  9. {  
  10.     [Activity(Label = "ProgressDialog", MainLauncher = true, Icon = "@drawable/icon")]  
  11.     public class MainActivity: Activity  
  12.     {  
  13.         Android.App.ProgressDialog progress;  
  14.         protected override void OnCreate(Bundle bundle)  
  15.         {  
  16.             base.OnCreate(bundle);  
  17.             // Set our view from the "main" layout resource  
  18.             SetContentView(Resource.Layout.Main);  
  19.             // Get our button from the layout resource,  
  20.             // and attach an event to it  
  21.             Button button = FindViewById < Button > (Resource.Id.MyButton);  
  22.             button.Click += delegate  
  23.             {  
  24.                 progress = new Android.App.ProgressDialog(this);  
  25.                 progress.Indeterminate = true;  
  26.                 progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);  
  27.                 progress.SetMessage("Loading... Please wait...");  
  28.                 progress.SetCancelable(false);  
  29.                 progress.Show();  
  30.             };  
  31.         }  
  32.     }  
  33. }  

Step 3: Press F5 or Build and Run the Application.

Finally, successfully created Xamarin Android ProgressDialog Application.

Ebook Download
View all
Learn
View all