Beispiel #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Detalhe);

            dbHelper = new DbHelperClass(this);

            var id = Intent.GetStringExtra("item");

            PreencheTela(id);

            Button voltar = FindViewById <Button>(Resource.Id.voltar);

            voltar.Click += delegate {
                this.Finish();
            };

            Button add = FindViewById <Button>(Resource.Id.add);

            add.Click += delegate {
                Utils.Display(this, dbHelper.insertRecord(data));
            };

            Button remove = FindViewById <Button>(Resource.Id.remove);

            remove.Click += delegate {
                Utils.Display(this, dbHelper.deleteRecord(data.Id));
            };
        }
        private void PreencheTela(View view)
        {
            DbHelperClass dbHelper = new DbHelperClass(this.Activity);

            mainList = view.FindViewById <ListView>(Resource.Id.mainlistview);

            var      forecastLista = dbHelper.selectRecords();
            TextView edit          = view.FindViewById <TextView>(Resource.Id.semFav);

            edit.Text = "A lista de favoritos esta vazia";
            if (forecastLista.Count() > 0)
            {
                foreach (var forecast in forecastLista)
                {
                    myObjectList.Add(new Data(forecast.Id, forecast.Name, forecast.Weather[0].Description, forecast.Main.Temp));
                }

                var favAdapter = new MyCustomAdapter(this, myObjectList);
                mainList.SetAdapter(favAdapter);
                edit.Text = string.Empty;
            }
        }