Пример #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

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

            // Get our controls
            _taskListView = FindViewById<ListView> (Resource.Id.lvTasks);
            Button button = FindViewById<Button> (Resource.Id.btnCreate);

            // Attach event handlers
            button.Click += delegate {
                StartActivity(typeof(TaskDetail));
            };

            _taskListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) =>{
                var taskDetails = new Intent(this, typeof(TaskDetail));
                taskDetails.PutExtra("TaskID", _tasks[e.Position].id);
                StartActivity(taskDetails);
            };

            // Initialize database
            _dbManager = new DatabaseManager(this);
        }
Пример #2
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			SetContentView (Resource.Layout.TaskDetail);
			// Create your application here
			_dbManager = new DatabaseManager (this);

			//Get the controls
			Button cancelButton = FindViewById<Button>(Resource.Id.btnCancel);
			Button deleteButton = FindViewById<Button>(Resource.Id.btnDelete);
			Button saveButton = FindViewById<Button>(Resource.Id.btnSave);

			//Check if this is a new task or an existing task
			_update = false;
			deleteButton.Visibility = ViewStates.Gone;
			int id = Intent.GetIntExtra ("TaskID", 0);
			if (id > 0)
			{
				_task = _dbManager.GetTask(id);
				UseExistingTask();
				deleteButton.Visibility = ViewStates.Visible;
				_update = true;
			}

			//bind the buttons
			cancelButton.Click += delegate {
				Finish();
			};

			saveButton.Click += delegate {
				Save();
				Finish ();
			};

			deleteButton.Click += delegate {
				Delete ();
				Finish ();
			};
			
		}
Пример #3
0
		private TaskManager()
		{
			_dbManager = new DatabaseManager(this);
		}