private void ShowNameEntry(bool continueToFinish = false)
        {
            global::Android.Support.V7.App.AlertDialog.Builder builder = new global::Android.Support.V7.App.AlertDialog.Builder(this);
            builder.SetTitle(Resource.String.actEnterUsernameTitle);

            int px = (int)global::Android.Util.TypedValue.ApplyDimension(
                global::Android.Util.ComplexUnitType.Dip, 16, base.Resources.DisplayMetrics);

            TextView message = new TextView(this);

            message.SetText(Resource.String.actEnterUsername);
            EditText nameInput = new EditText(this)
            {
                Text = enteredName
            };

            LinearLayout dialogLayout = new LinearLayout(this)
            {
                Orientation = Orientation.Vertical
            };

            dialogLayout.AddView(message);
            dialogLayout.AddView(nameInput);
            dialogLayout.SetPadding(px, px, px, px);

            builder.SetView(dialogLayout);
            builder.SetNeutralButton(Resource.String.dialog_cancel, (a, b) => { });
            builder.SetPositiveButton(Resource.String.dialog_ok, (a, b) =>
            {
                if (string.IsNullOrWhiteSpace(nameInput.Text))
                {
                    // If nothing has been entered and nothing has been previously
                    // entered, show the dialog again
                    if (string.IsNullOrWhiteSpace(enteredName))
                    {
                        ShowNameEntry();
                    }
                }
                else
                {
                    enteredName = nameInput.Text;
                    adapter.UpdateNames(enteredName);
                    dbManager.SaveActivityProgress(learningActivity, adapter.Items, enteredName);

                    if (continueToFinish)
                    {
                        PackageForUpload();
                    }
                }
            });

            if (!string.IsNullOrWhiteSpace(enteredName))
            {
                builder.SetNeutralButton(Resource.String.dialog_cancel, (a, b) => { });
            }

            builder.Show();
        }
        private void StartSearch()
        {
#pragma warning disable CA2000 // Dispose objects before losing scope
            EditText codeInput = new EditText(this);
#pragma warning restore CA2000 // Dispose objects before losing scope

            using (global::Android.Support.V7.App.AlertDialog.Builder builder = new global::Android.Support.V7.App.AlertDialog.Builder(this))
                using (TextView message = new TextView(this))
                    using (LinearLayout dialogLayout = new LinearLayout(this)
                    {
                        Orientation = Orientation.Vertical
                    })
                    {
                        builder.SetTitle(Resource.String.searchAlertTitle);
                        int px = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 16, Resources.DisplayMetrics);
                        message.SetText(Resource.String.createCollectionAddActivityEnterCode);

                        dialogLayout.AddView(message);
                        dialogLayout.AddView(codeInput);
                        dialogLayout.SetPadding(px, px, px, px);

                        builder.SetView(dialogLayout);
                        builder.SetPositiveButton(Resource.String.MenuSearch, (a, b) => { GetAndReturnWithActivity(codeInput.Text); codeInput.Dispose(); });
                        builder.SetNeutralButton(Resource.String.dialog_cancel, (a, b) => { });
                        builder.Show();
                    }
        }
示例#3
0
        private void StartSearch()
        {
            global::Android.Support.V7.App.AlertDialog.Builder builder = new global::Android.Support.V7.App.AlertDialog.Builder(this);
            builder.SetTitle(Resource.String.searchAlertTitle);

            int px = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 16, Resources.DisplayMetrics);

            TextView message = new TextView(this);

            message.SetText(Resource.String.searchAlertMessage);
            EditText codeInput = new EditText(this);

            LinearLayout dialogLayout = new LinearLayout(this)
            {
                Orientation = Orientation.Vertical
            };

            dialogLayout.AddView(message);
            dialogLayout.AddView(codeInput);
            dialogLayout.SetPadding(px, px, px, px);

            builder.SetView(dialogLayout);
            builder.SetPositiveButton(Resource.String.MenuSearch, (a, b) => { GetAndOpenActivity(codeInput.Text); });
            builder.SetNeutralButton(Resource.String.dialog_cancel, (a, b) => { });
            builder.Show();
        }