void AddProfile()
        {
            var alert = new AlertDialog.Builder(this);

            alert.SetTitle("Nieuw profiel");
            var input = new EditText(this);

            input.InputType = Android.Text.InputTypes.TextFlagCapWords;
            input.Hint      = "Naam";
            KeyboardHelper.ShowKeyboard(this, input);
            alert.SetView(input);
            alert.SetPositiveButton("Ok", (sender, args) => {
                string value = input.Text;
                if (value.Replace("'", "").Replace(" ", "").Equals(""))
                {
                    mToast.SetText("Ongeldige naam");
                    mToast.Show();
                }
                else if (_appController.GetProfielNamen().Contains(value))
                {
                    input.Text = "";
                    mToast.SetText("Profiel " + value + " bestaat al");
                    mToast.Show();
                }
                else
                {
                    _appController.AddProfile(value);
                    UpdateList();
                }
            });

            AlertDialog d1 = alert.Create();

            //add profile when enter is clicked
            input.EditorAction += (sender, e) => {
                if (e.ActionId == ImeAction.Done)
                {
                    d1.GetButton(-1).PerformClick();
                }
                else
                {
                    e.Handled = false;
                }
            };

            RunOnUiThread(d1.Show);
        }
 //toggles the search bar
 void ToggleSearch()
 {
     if (query.Visibility == ViewStates.Visible)
     {
         HideSearch();
     }
     else
     {
         back.Visibility  = ViewStates.Gone;
         title.Visibility = ViewStates.Gone;
         query.Visibility = ViewStates.Visible;
         KeyboardHelper.ShowKeyboard(this, query);
         query.Text = "";
         query.RequestFocus();
         search.SetImageResource(Resource.Drawable.ic_close_white_24dp);
     }
 }
        private void ProfilePopup()
        {
            var menu = new PopupMenu(this, search);

            menu.Inflate(Resource.Menu.Popup);
            int count = 0;

            foreach (Profiel p in _appController.DistinctProfielen)
            {
                menu.Menu.Add(0, count, count, p.name);
                count++;
            }

            menu.Menu.Add(0, count, count, "Nieuw profiel");

            menu.MenuItemClick += (s1, arg1) => {
                if (arg1.Item.ItemId == count)
                {
                    var alert = new AlertDialog.Builder(this);
                    alert.SetTitle("Nieuw profiel");
                    var input = new EditText(this);
                    input.InputType = InputTypes.TextFlagCapWords;
                    input.Hint      = "Naam";
                    KeyboardHelper.ShowKeyboard(this, input);
                    alert.SetView(input);
                    alert.SetPositiveButton("Ok", (s, args) => {
                        string value = input.Text;
                        if (value.Replace("'", "").Replace(" ", "").Equals(""))
                        {
                            mToastShort.SetText("Ongeldige naam");
                            mToastShort.Show();
                        }
                        else if (_appController.GetProfielNamen().Contains(value))
                        {
                            input.Text = "";
                            mToastShort.SetText("Profiel " + value + " bestaat al");
                            mToastShort.Show();
                        }
                        else
                        {
                            _appController.AddProfile(value);
                            _appController.AddOrUpdateEigenschappenSer(value, JsonSerializer.SerializeToString(_appController.Eigenschappen));
                            mToastShort.SetText("Selectie opgeslagen voor profiel " + value);
                            mToastShort.Show();
                        }
                    });

                    AlertDialog d1 = alert.Create();

                    //add profile when enter is clicked
                    input.EditorAction += (s2, e) => {
                        if (e.ActionId == ImeAction.Done)
                        {
                            d1.GetButton(-1).PerformClick();
                        }
                        else
                        {
                            e.Handled = false;
                        }
                    };

                    RunOnUiThread(d1.Show);
                }
                else
                {
                    _appController.AddOrUpdateEigenschappenSer(arg1.Item.TitleFormatted.ToString(), JsonSerializer.SerializeToString(_appController.Eigenschappen));
                    mToastShort.SetText("Selectie opgeslagen voor profiel " + arg1.Item.TitleFormatted);
                    mToastShort.Show();
                }
            };

            menu.Show();
        }