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:-

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); 
 // Set our view from the "main" layout resource 
 SetContentView(Resource.Layout.Main); 
 // Get our button from the layout resource, 
 // and attach an event to it 
 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.

Download Source here

Finally, successfully created Xamarin Android ProgressDialog Application.

Leave a Comment

Your email address will not be published. Required fields are marked *