I have created the following alert dialog and progressbar:
LayoutInflater layoutInflater = LayoutInflater.From(this);
View progressDialogBox = layoutInflater.Inflate(Resource.Layout.progress_dialog_box, null);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.SetView(progressDialogBox);
var progressBar1 = progressDialogBox.FindViewById<ProgressBar>(Resource.Id.progressBar1);
progressBar1.Max = 100;
progressBar1.Progress = 0;
Dialog dialog = alertDialogBuilder.Create();
dialog.Show();
And I make it increase every 2 seconds
System.Threading.Thread.Sleep(2000);
progressBar1.IncrementProgressBy(25);
System.Threading.Thread.Sleep(2000);
progressBar1.IncrementProgressBy(25);
System.Threading.Thread.Sleep(2000);
progressBar1.IncrementProgressBy(25);
System.Threading.Thread.Sleep(2000);
progressBar1.IncrementProgressBy(25);
progress_dialog_box.axml contains that code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="Getting data..."
android:layout_gravity="center"
android:paddingTop="40dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar1" />
</LinearLayout>
But when I run the application the ProgressBar stays at 0. How can I make it progress?