示例#1
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;
        }