コード例 #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.AllEigenschappen);

            //Action bar
            InitializeActionBar(SupportActionBar);
            title  = ActionBarTitle;
            query  = ActionBarQuery;
            search = ActionBarSearch;
            back   = ActionBarBack;

            mToastShort = Toast.MakeText(this, "", ToastLength.Short);
            mToastLong  = Toast.MakeText(this, "", ToastLength.Long);

            currProfiel       = _appController.CurrentProfiel;
            IsProfileNull     = (currProfiel == null);
            eigenschappenList = _appController.Eigenschappen;

            //listener to pass to EigenschapAdapter containing context
            mListener = new MyOnCheckBoxClickListener(this);

            eigenschapAdapter                = new EigenschapAdapter(this, _appController.Eigenschappen, mListener);
            allEigenschappenListView         = FindViewById <ListView> (Resource.Id.all_eigenschappen_list);
            allEigenschappenListView.Adapter = eigenschapAdapter;

            title.Text = IsProfileNull ? "Eigenschappen" : "Selectie";
            query.Hint = "Zoek eigenschap";

            //hide keyboard when scrolling through list
            allEigenschappenListView.SetOnTouchListener(new MyOnTouchListener(this, query));

            //initialize progress dialog used when calculating totemlist
            progress = new ProgressDialog(this);
            progress.SetMessage("Totems zoeken...");
            progress.SetProgressStyle(ProgressDialogStyle.Spinner);
            progress.SetCancelable(false);

            LiveSearch();

            sharedPrefs = GetSharedPreferences("data", FileCreationMode.Private);

            var vind = FindViewById <LinearLayout> (Resource.Id.vind);

            vind.Click += VindTotem;

            bottomBar = FindViewById <RelativeLayout> (Resource.Id.bottomBar);

            search.Visibility = ViewStates.Visible;
            search.Click     += (sender, e) => ToggleSearch();

            //hide keyboard when enter is pressed
            query.EditorAction += (sender, e) => {
                if (e.ActionId == ImeAction.Search)
                {
                    KeyboardHelper.HideKeyboard(this);
                }
                else
                {
                    e.Handled = false;
                }
            };
        }
コード例 #2
0
        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();
        }