Exemple #1
0
        private void SetContent()
        {
            List <DBModel.Item> mItems = new List <DBModel.Item>();

            DBAccess.DBInterface db = new DBAccess.DBInterface();
            try
            {
                mItems = db.GetALlItems();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (db != null)
                {
                    db.Disconnect();
                }
            }

            ListView listView             = FindViewById <ListView>(Resource.Id.listViewItems);
            CustomListItemAdapter adapter = new CustomListItemAdapter(this, mItems);

            listView.Adapter    = adapter;
            listView.ItemClick += listView_ItemClick;
        }
        private void SetContent()
        {
            DBAccess.DBInterface db = null;
            try
            {
                db = new DBAccess.DBInterface();
                DBModel.Item        item            = db.GetItem(ItemId);
                List <DBModel.Item> adapterItemList = new List <DBModel.Item>()
                {
                    item
                };

                ListView view = FindViewById(Resource.Id.listViewItemEdit) as ListView;
                CustomListItemAdapter adapter = new CustomListItemAdapter(this, adapterItemList);
                view.Adapter = adapter;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (db != null)
                {
                    db.Disconnect();
                }
            }
        }
Exemple #3
0
        private void okClick()
        {
            TextView   textAddName = FindViewById <Android.Widget.TextView>(Resource.Id.editTextAddName);
            TextView   textAddDate = FindViewById <Android.Widget.TextView>(Resource.Id.editTextDateItem);
            TimePicker time        = FindViewById <Android.Widget.TimePicker>(Resource.Id.timePickerActivitime);
            DateTime   date;


            bool parsed = DateTime.TryParse(textAddDate.Text, out date);

            date = date.Date.AddHours(Convert.ToDouble(time.CurrentHour.ToString())).AddMinutes(Convert.ToDouble(time.CurrentMinute.ToString()));
            if (parsed)
            {
                DBAccess.DBInterface db = new DBAccess.DBInterface();
                try
                {
                    db.AddNewItem(textAddName.Text, date);
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    if (db != null)
                    {
                        db.Disconnect();
                    }
                }

                var activityMain = new Intent(this, typeof(MainActivity));
                activityMain.PutExtra("MyData", "Data from Activity1");
                StartActivity(activityMain);
            }
            else
            {
                textAddDate.Text = "";
                textAddDate.Hint = "Required Format: 'DD.MM.YYYY'";
            }
        }
        private void BtnDeleteClick()
        {
            DBAccess.DBInterface db = null;
            try
            {
                db = new DBAccess.DBInterface();
                db.DeleteItem(ItemId);
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (db != null)
                {
                    db.Disconnect();
                }
            }

            var activityMain = new Intent(this, typeof(MainActivity));

            activityMain.PutExtra("MyData", "Data from Activity1");
            StartActivity(activityMain);
        }