示例#1
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            ProfileService profileService = new ProfileService();
            var            tag            = (sender as Button).Tag;

            profileService.Delete(tag.ToString());
        }
示例#2
0
        private void MainActivity_Click(object sender, EventArgs e)
        {
            ProfileService profileService = new ProfileService();

            profileService.AddProfile(GetProfile());
            LoadDataToListView();
        }
示例#3
0
        private void LoadDataToListView()
        {
            ProfileService profileService = new ProfileService();
            var            profiles       = profileService.GetAll();

            var listView = FindViewById <ListView>(Resource.Id.myListView);

            var profileAdapter = new ProfileAdapter <Profile>(this, profiles, Resource.Layout.ListItem, (v, t) =>
            {
                v.FindViewById <TextView>(Resource.Id.txtAddress).Text = t.Address;
                v.FindViewById <TextView>(Resource.Id.txtAge).Text     = t.Age.ToString();
                v.FindViewById <TextView>(Resource.Id.txtName).Text    = t.UserName.ToString();

                var btnDelete    = v.FindViewById <Button>(Resource.Id.btnDelete);
                btnDelete.Tag    = t.ID;
                btnDelete.Click += BtnDelete_Click;
            });

            listView.Adapter = profileAdapter;
        }