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

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.AddGoalScreen);

            // Find all the controls
            taskDescriptionInput   = FindViewById <EditText>(Resource.Id.taskDescriptionInput);
            taskDaysPerPeriodInput = FindViewById <EditText>(Resource.Id.taskDaysPerPeriodInput);
            daysInPeriodInput      = FindViewById <EditText>(Resource.Id.daysInPeriodInput);
            periodsPerGoalInput    = FindViewById <EditText>(Resource.Id.periodsPerGoalInput);
            rewardDescriptionInput = FindViewById <EditText>(Resource.Id.rewardDescriptionInput);

            Button addGoalButton = FindViewById <Button>(Resource.Id.addGoalButton);
            Button cancelButton  = FindViewById <Button>(Resource.Id.cancelButton);


            addGoalButton.Click += delegate
            {
                // TODO: Handle missing/invalid input.
                String taskDescription = taskDescriptionInput.Text;
                taskDescription = String.IsNullOrWhiteSpace(taskDescription) ? GetString(Resource.String.default_taskname) : taskDescription;

                int taskDaysPerPeriod;
                Int32.TryParse(taskDaysPerPeriodInput.Text, out taskDaysPerPeriod);
                int daysInPeriod;
                Int32.TryParse(daysInPeriodInput.Text, out daysInPeriod);
                int periodsPerGoal;
                Int32.TryParse(periodsPerGoalInput.Text, out periodsPerGoal);
                String rewardDescription = rewardDescriptionInput.Text;

                Goal        g           = new Goal(taskDescription, taskDaysPerPeriod, daysInPeriod, periodsPerGoal, rewardDescription);
                GoalManager goalManager = GoalManager.getInstance();
                goalManager.AddGoal(g);
                Finish();
            };

            cancelButton.Click += delegate
            {
                Finish();
            };
        }