Exemplo n.º 1
0
        private void ShowModeConfigurationDialog(int joystickId)
        {
            // Build and display the mode configuration dialog
            AlertDialog modeConfigurationDialog = null;

            AlertDialog.Builder builder = new AlertDialog.Builder(Activity, Resource.Style.AlertDialogStyle);

            builder.SetSingleChoiceItems(Resource.Array.JoystickModes,
                                         (int)GetRelatedJoystickConfiguration(joystickId).JoystickMode,
                                         delegate(object sender, DialogClickEventArgs args)
            {
                ConfigureJoystickAxis((JoystickConfiguration.JoystickModes)args.Which, joystickId);

                // ReSharper disable once AccessToModifiedClosure
                modeConfigurationDialog?.Dismiss();
            });

            builder.SetPositiveButton(Resource.String.ControlInterfaceActivity_configureJoystickModeDialogPositive,
                                      delegate
            {
                // ReSharper disable once AccessToModifiedClosure
                modeConfigurationDialog?.Dismiss();
            });


            builder.SetTitle(Resource.String.ControlInterfaceActivity_configureJoystickModeDialogTitle);
            builder.SetCancelable(false);

            modeConfigurationDialog = builder.Create();

            modeConfigurationDialog.Show();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Open a popup to enter a new recipient
        /// </summary>
        private void AddRecipientFromPopupButton_Click(object sender, EventArgs e)
        {
            Android.Support.V7.App.AlertDialog addRecipientDialog = null;
            var addRecipientBuilder = new Android.Support.V7.App.AlertDialog.Builder(this, Resource.Style.Theme_AppCompat_Light_Dialog);
            var view = LayoutInflater.Inflate(Resource.Drawable.AddRecipient, null);

            addRecipientBuilder.SetTitle(Resource.String.alertSOS_popupTitle);
            addRecipientBuilder.SetPositiveButton(Resource.String.alertSOS_popupPositive, new EventHandler <DialogClickEventArgs>((o, ev) => { }));
            addRecipientBuilder.SetNegativeButton(Resource.String.alertSOS_popupNegative, new EventHandler <DialogClickEventArgs>((o, ev) =>
            {
                addRecipientDialog.Dismiss();
            }));

            addRecipientBuilder.SetView(view);
            addRecipientDialog            = addRecipientBuilder.Create();
            addRecipientDialog.ShowEvent += (ee, oo) =>
            {
                var button = addRecipientDialog.GetButton((int)Android.Content.DialogButtonType.Positive);
                button.Click += (eee, ooo) =>
                {
                    var displayNameEditText = view.FindViewById <EditText>(Resource.Id.addRecipient_contact);
                    var emailEditText       = view.FindViewById <EditText>(Resource.Id.addRecipient_email);

                    // empty display name
                    if (string.IsNullOrEmpty(displayNameEditText.Text))
                    {
                        displayNameEditText.Error = Resources.GetString(Resource.String.alertSOS_popupEmptyField);
                    }
                    // empty email
                    else if (string.IsNullOrEmpty(emailEditText.Text))
                    {
                        emailEditText.Error = Resources.GetString(Resource.String.alertSOS_popupEmptyField);
                    }
                    // invalide email
                    else if (!Android.Util.Patterns.EmailAddress.Matcher(emailEditText.Text).Matches())
                    {
                        emailEditText.Error = Resources.GetString(Resource.String.alertSOS_popupEmail);
                    }
                    // add the contact
                    else
                    {
                        displayNameEditText.Error = null;
                        emailEditText.Error       = null;

                        App.Locator.Alert.LsRecipients.Add(new AlertRecipientDTO
                        {
                            DisplayName = displayNameEditText.Text,
                            Email       = emailEditText.Text
                        });

                        _selectedContact = new Contact {
                            DisplayName = displayNameEditText.Text, Email = emailEditText.Text
                        };
                        AlertRecipientLayout.AddChild(_selectedContact);
                        addRecipientDialog.Dismiss();
                    }
                };
            };
            addRecipientDialog.Show();
        }
Exemplo n.º 3
0
        private void ShowMotorConfigurationDialog(int joystickId, int joystickAxis)
        {
            // Build and display the motor configuration dialog
            AlertDialog motorConfigurationDialog = null;

            AlertDialog.Builder builder = new AlertDialog.Builder(Activity, Resource.Style.AlertDialogStyle);

            builder.SetSingleChoiceItems(GetMotorList(),
                                         GetRelatedJoystickConfiguration(joystickId).MotorIndexes[joystickAxis],
                                         delegate(object sender, DialogClickEventArgs args)
            {
                // When one motor was clicked we set it and display the next dialog
                SetMotorIndex(joystickId, args.Which, joystickAxis);

                // ReSharper disable once AccessToModifiedClosure
                motorConfigurationDialog?.Dismiss();


                // If configured the first joystick axis we have to configure the second.
                // This can be done better but it works :)
                if (joystickAxis == 0)
                {
                    ShowMotorConfigurationDialog(joystickId, ++joystickAxis);
                }
            });

            builder.SetPositiveButton(Resource.String.ControlInterfaceActivity_configureJoystickMotor1DialogPositive,
                                      delegate
            {
                // ReSharper disable once AccessToModifiedClosure
                motorConfigurationDialog?.Dismiss();

                // If configured the first joystick axis we have to configure the second.
                if (joystickAxis == 0)
                {
                    ShowMotorConfigurationDialog(joystickId, ++joystickAxis);
                }
            });

            if (joystickAxis == 0)
            {
                builder.SetTitle(Resource.String.ControlInterfaceActivity_configureJoystickMotor1DialogTitle);
            }
            else if (joystickAxis == 1)
            {
                builder.SetTitle(Resource.String.ControlInterfaceActivity_configureJoystickMotor2DialogTitle);
            }

            builder.SetCancelable(false);

            motorConfigurationDialog = builder.Create();

            motorConfigurationDialog.Show();
        }
 void CloseProgressDialogue()
 {
     if (alert != null)
     {
         alertDialog.Dismiss();
         alertDialog = null;
         alert       = null;
     }
 }
Exemplo n.º 5
0
 public void CloseDialog()
 {
     if (alertDialog != null)
     {
         alertDialog.Dismiss();
         alertDialog  = null;
         alertBuilder = null;
     }
 }
Exemplo n.º 6
0
        private void AccBtn_Click(object sender, EventArgs p)
        {
            BluetoothHolder.bluetoothManage.Read();
            OKBtn.Enabled  = true;
            AccBtn.Enabled = false;

            if (DatabaseHolder.CODE() == "OK")
            {
                Toast.MakeText(this.Activity, "Received: " + DatabaseHolder.receiver, ToastLength.Long).Show();
            }
            else if (DatabaseHolder.CODE() == "ER")
            {
                Toast.MakeText(this.Activity, "There was an error while uploading a database!", ToastLength.Long).Show();
            }
            else
            {
                Toast.MakeText(this.Activity, "UNKNOWN ERROR - RECEIVED MSG:'" + DatabaseHolder.receiver + "'", ToastLength.Long).Show();
            }
            alertDialogAndroid.Dismiss();
        }
Exemplo n.º 7
0
        private void SetAlarm(DateTime sentAt)
        {
            Intent   i    = new Intent(AlarmClock.ActionSetAlarm);
            TimeSpan span = sentAt.TimeOfDay;

            span = span.Subtract(TimeSpan.FromMinutes(AvailableTime[time]));
            i.PutExtra(AlarmClock.ExtraHour, span.Hours);
            i.PutExtra(AlarmClock.ExtraMinutes, span.Minutes);
            i.PutExtra(AlarmClock.ExtraSkipUi, true);
            i.PutExtra(AlarmClock.ExtraMessage, Context.Resources.GetString(Resource.String.app_name) + " " + AvailableTime[time].ToString() + " " + Context.Resources.GetString(Resource.String.mins) + " " + Context.Resources.GetString(Resource.String.Left));
            i.PutExtra(AlarmClock.ExtraVibrate, true);

            Context.StartActivity(i);
            alertDialog.Dismiss();
        }
        private void FilterTransactions()
        {
            var day     = spinnerDay.SelectedItemPosition;
            var month   = spinnerMonth.SelectedItemPosition;
            var year    = listOfYears[spinnerYear.SelectedItemPosition];
            var account = listOfAccounts[spinnerAccounts.SelectedItemPosition];

            if (day != 0 && month == 0)
            {
                Toast.MakeText(Activity, "Month must be selected!", ToastLength.Short).Show();
            }
            else
            {
                transactions       = SilverCoinsManager.GetTransactionsByDate(day, month, year, account.Id);
                transactionAdapter = new TransactionListAdapter(Activity, transactions, account);
                listView.Adapter   = transactionAdapter;
                showIntervalDialog.Dismiss();
            }
        }
Exemplo n.º 9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_register);

            xamarinAPI = RestService.For <XamarinAPI>("http://localhost:5000");

            alertDialog = new EDMTDialogBuilder().SetContext(this).Build();

            etPassword  = FindViewById <EditText>(Resource.Id.etPassword);
            etUsername  = FindViewById <EditText>(Resource.Id.etUsername);
            btnRegister = FindViewById <Button>(Resource.Id.btnRegister);


            btnRegister.Click += async delegate
            {
                alertDialog.Show();

                TbUser user = new TbUser();
                user.Username = etUsername.Text;
                user.Password = etPassword.Text;

                var result = await xamarinAPI.RegisterUser(user);

                if (result.Contains("successfully"))
                {
                    Finish();
                }

                Toast.MakeText(this, result, ToastLength.Short).Show();

                alertDialog.Dismiss();
            };

            // Create your application here
        }
Exemplo n.º 10
0
        private void ImgButtonOnClick(ReactionsClickEventArgs e)
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(Application.Context, Application.Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                    return;
                }

                if (UserDetails.SoundControl)
                {
                    Methods.AudioRecorderAndPlayer.PlayAudioFromAsset("reaction.mp3");
                }

                PostData.CommentObject.Reaction ??= new WoWonderClient.Classes.Posts.Reaction();

                PostData.CommentObject.Reaction.Count++;

                if (!PostData.CommentObject.Reaction.IsReacted)
                {
                    PostData.CommentObject.Reaction.IsReacted = true;
                }

                var data = MReactionPack[e.Position];
                if (data != null)
                {
                    SetReactionPack(PostData.Holder, data.GetReactText());
                    PostData.Holder.LikeTextView.Tag = "Liked";
                }

                string reactionType = "reaction_comment";
                if (TypeClass == "Reply")
                {
                    reactionType = "reaction_reply";
                }

                if (e.React == ReactConstants.Like)
                {
                    PostData.CommentObject.Reaction.Type = "Like";
                    PostData.CommentObject.Reaction.Like++;
                    PostData.CommentObject.Reaction.Like1++;

                    string react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Name == "Like").Value?.Id ?? "1";
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Comment.ReactionCommentAsync(PostData.CommentObject.Id, react, reactionType)
                    });
                }
                else if (e.React == ReactConstants.Love)
                {
                    PostData.CommentObject.Reaction.Type = "Love";
                    PostData.CommentObject.Reaction.Love++;
                    PostData.CommentObject.Reaction.Love2++;
                    string react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Name == "Love").Value?.Id ?? "2";
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Comment.ReactionCommentAsync(PostData.CommentObject.Id, react, reactionType)
                    });
                }
                else if (e.React == ReactConstants.HaHa)
                {
                    PostData.CommentObject.Reaction.Type = "HaHa";
                    PostData.CommentObject.Reaction.HaHa++;
                    PostData.CommentObject.Reaction.HaHa3++;
                    string react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Name == "HaHa").Value?.Id ?? "3";
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Comment.ReactionCommentAsync(PostData.CommentObject.Id, react, reactionType)
                    });
                }
                else if (e.React == ReactConstants.Wow)
                {
                    PostData.CommentObject.Reaction.Type = "Wow";
                    PostData.CommentObject.Reaction.Wow++;
                    PostData.CommentObject.Reaction.Wow4++;
                    string react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Name == "Wow").Value?.Id ?? "4";
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Comment.ReactionCommentAsync(PostData.CommentObject.Id, react, reactionType)
                    });
                }
                else if (e.React == ReactConstants.Sad)
                {
                    PostData.CommentObject.Reaction.Type = "Sad";
                    PostData.CommentObject.Reaction.Sad++;
                    PostData.CommentObject.Reaction.Sad5++;
                    string react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Name == "Sad").Value?.Id ?? "5";
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Comment.ReactionCommentAsync(PostData.CommentObject.Id, react, reactionType)
                    });
                }
                else if (e.React == ReactConstants.Angry)
                {
                    PostData.CommentObject.Reaction.Type = "Angry";
                    PostData.CommentObject.Reaction.Angry++;
                    PostData.CommentObject.Reaction.Angry6++;
                    string react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Name == "Angry").Value?.Id ?? "6";
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Comment.ReactionCommentAsync(PostData.CommentObject.Id, react, reactionType)
                    });
                }

                MReactAlertDialog.Dismiss();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Exemplo n.º 11
0
        private void ImgButtonOnClick(ReactionsClickEventArgs e)
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(Application.Context, Application.Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
                    return;
                }

                if (UserDetails.SoundControl)
                {
                    Methods.AudioRecorderAndPlayer.PlayAudioFromAsset("reaction.mp3");
                }

                PostData.CommentObject.Reaction ??= new WoWonderClient.Classes.Posts.Reaction();

                if (PostData.CommentObject.Reaction.IsReacted != null && !PostData.CommentObject.Reaction.IsReacted.Value)
                {
                    PostData.CommentObject.Reaction.IsReacted = true;
                    PostData.CommentObject.Reaction.Count++;
                }

                if (PostData.Holder.CountLike != null && PostData.CommentObject.Reaction.Count > 0)
                {
                    PostData.Holder.CountLikeSection.Visibility = ViewStates.Visible;
                    PostData.Holder.CountLike.Text = Methods.FunString.FormatPriceValue(PostData.CommentObject.Reaction.Count);
                }
                else
                {
                    PostData.Holder.CountLikeSection.Visibility = ViewStates.Gone;
                }

                var data = MReactionPack[e.Position];
                if (data != null)
                {
                    SetReactionPack(PostData.Holder, data.GetReactText());
                    PostData.Holder.LikeTextView.Tag = "Liked";
                }

                string reactionType = "reaction_comment";
                if (TypeClass == "Reply")
                {
                    reactionType = "reaction_reply";
                }

                if (e.React == ReactConstants.Like)
                {
                    PostData.Holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_like);

                    PostData.CommentObject.Reaction.Type = "1";
                    string react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Name == "Like").Value?.Id ?? "1";
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Comment.ReactionCommentAsync(PostData.CommentObject.Id, react, reactionType)
                    });
                }
                else if (e.React == ReactConstants.Love)
                {
                    PostData.Holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_love);

                    PostData.CommentObject.Reaction.Type = "2";
                    string react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Name == "Love").Value?.Id ?? "2";
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Comment.ReactionCommentAsync(PostData.CommentObject.Id, react, reactionType)
                    });
                }
                else if (e.React == ReactConstants.HaHa)
                {
                    PostData.Holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_haha);

                    PostData.CommentObject.Reaction.Type = "3";
                    string react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Name == "HaHa").Value?.Id ?? "3";
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Comment.ReactionCommentAsync(PostData.CommentObject.Id, react, reactionType)
                    });
                }
                else if (e.React == ReactConstants.Wow)
                {
                    PostData.Holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_wow);

                    PostData.CommentObject.Reaction.Type = "4";
                    string react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Name == "Wow").Value?.Id ?? "4";
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Comment.ReactionCommentAsync(PostData.CommentObject.Id, react, reactionType)
                    });
                }
                else if (e.React == ReactConstants.Sad)
                {
                    PostData.Holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_sad);

                    PostData.CommentObject.Reaction.Type = "5";
                    string react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Name == "Sad").Value?.Id ?? "5";
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Comment.ReactionCommentAsync(PostData.CommentObject.Id, react, reactionType)
                    });
                }
                else if (e.React == ReactConstants.Angry)
                {
                    PostData.Holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_angry);

                    PostData.CommentObject.Reaction.Type = "6";
                    string react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Name == "Angry").Value?.Id ?? "6";
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Comment.ReactionCommentAsync(PostData.CommentObject.Id, react, reactionType)
                    });
                }

                MReactAlertDialog.Dismiss();
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
Exemplo n.º 12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_start);

            db = new Userdatabase();
            db.createDatabase();

            /*if (db.confirmTable(MainActivity.username) == 0)
             * {
             *  Save_username();
             * }*/

            button_start  = FindViewById <Button>(Resource.Id.btn_start);
            button_resume = FindViewById <Button>(Resource.Id.btn_resume);
            button_exit   = FindViewById <Button>(Resource.Id.btn_exit);
            title_text    = FindViewById <TextView>(Resource.Id.txt_title);
            user_text     = FindViewById <TextView>(Resource.Id.txt_username);
            newuser_text  = FindViewById <TextView>(Resource.Id.txt_newuser);
            olduser_text  = FindViewById <TextView>(Resource.Id.txt_olduser);
            linear_resume = FindViewById <LinearLayout>(Resource.Id.linear_resume);

            user_text.Text = "Welcome " + MainActivity.username;

            Spinner spinner_cate = FindViewById <Spinner>(Resource.Id.spinner_category);

            spinner_cate.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(Spinner_cate_ItemSelected);
            var adapter = ArrayAdapter.CreateFromResource(this, Resource.Array.category_array, Android.Resource.Layout.SimpleSpinnerItem);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinner_cate.Adapter = adapter;

            Spinner spinner_level = FindViewById <Spinner>(Resource.Id.spinner_level);

            spinner_level.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(Spinner_level_ItemSelected);
            var adapter1 = ArrayAdapter.CreateFromResource(this, Resource.Array.level_array, Android.Resource.Layout.SimpleSpinnerItem);

            adapter1.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinner_level.Adapter = adapter1;

            Typeface tf1 = Typeface.CreateFromAsset(Assets, "Sketch.ttf");
            Typeface tf2 = Typeface.CreateFromAsset(Assets, "Romantic Beach.ttf");
            Typeface tf3 = Typeface.CreateFromAsset(Assets, "Sin City.ttf");
            Typeface tf4 = Typeface.CreateFromAsset(Assets, "SouthernAire_Personal_Use_Only.ttf");

            title_text.Typeface = tf4;

            Show_resumlinear();

            newuser_text.Click += delegate
            {
                LayoutInflater layoutInflater = LayoutInflater.From(this);
                View           view           = layoutInflater.Inflate(Resource.Layout.user_input_dialog_box, null);
                Android.Support.V7.App.AlertDialog.Builder alertbuilder = new Android.Support.V7.App.AlertDialog.Builder(this);
                alertbuilder.SetView(view);
                alertbuilder.SetPositiveButton("Create", (EventHandler <DialogClickEventArgs>)null);
                alertbuilder.SetNegativeButton("Cancel", (EventHandler <DialogClickEventArgs>)null);
                nameedit    = view.FindViewById <EditText>(Resource.Id.edit_name);
                titl_dialog = view.FindViewById <TextView>(Resource.Id.dialogTitle);
                alertbuilder.SetCancelable(false);
                Android.Support.V7.App.AlertDialog dialog = alertbuilder.Create();
                dialog.Show();
                var createBtn = dialog.GetButton((int)DialogButtonType.Positive);
                var cancelBtn = dialog.GetButton((int)DialogButtonType.Negative);
                createBtn.Click += (sender, args) =>
                {
                    string m_username = nameedit.Text;
                    if (m_username.Equals(""))
                    {
                        titl_dialog.Text = "You have no name";
                    }
                    else
                    {
                        if (db.confirmTable(m_username) == 0)
                        {
                            MainActivity.username = m_username;
                            user_text.Text        = "Welcome " + MainActivity.username;
                            Save_username();
                            dialog.Dismiss();
                        }
                        else
                        {
                            titl_dialog.Text = "This user is already";
                        }
                    }
                };
                cancelBtn.Click += (sender, args) =>
                {
                    // Dismiss dialog.
                    Console.WriteLine("I will dismiss now!");
                    dialog.Dismiss();
                };
            };

            olduser_text.Click += delegate
            {
                LayoutInflater layoutInflater = LayoutInflater.From(this);
                View           view           = layoutInflater.Inflate(Resource.Layout.username_select_dialog_box, null);
                Android.Support.V7.App.AlertDialog.Builder alertbuilder = new Android.Support.V7.App.AlertDialog.Builder(this);
                alertbuilder.SetView(view);
                userlist = view.FindViewById <ListView>(Resource.Id.list_user);
                alertbuilder.SetNegativeButton("Cancel", (EventHandler <DialogClickEventArgs>)null);
                alertbuilder.SetCancelable(false);
                Android.Support.V7.App.AlertDialog dialog = alertbuilder.Create();
                dialog.Show();
                var cancelBtn = dialog.GetButton((int)DialogButtonType.Negative);

                listSource = db.selectTable();
                var adapter11 = new UserListAdapter(this, listSource);
                userlist.Adapter         = adapter11;
                this.userlist.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) =>
                {
                    string name111 = listSource[e.Position].Name;
                    MainActivity.username = name111;
                    user_text.Text        = "Welcome " + MainActivity.username;
                    dialog.Dismiss();
                };
                cancelBtn.Click += (sender, args) =>
                {
                    // Dismiss dialog.
                    Console.WriteLine("I will dismiss now!");
                    dialog.Dismiss();
                };
            };

            button_start.Click += delegate
            {
                MainActivity.arrayname = flag_category;
                MainActivity.levelname = flag_level;
                if (!flag_category.Equals("-- Select --"))
                {
                    Click_Start();
                }
                else
                {
                    Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                    AlertDialog alert = dialog.Create();
                    alert.SetTitle("Warning!");
                    alert.SetMessage("Please select a category");
                    alert.SetButton("OK", (c, ev) =>
                    {
                    });
                    alert.Show();
                }
            };

            button_exit.Click += delegate
            {
                Exit();
            };
        }