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

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

            var button   = this.FindViewById <Button>(Resource.Id.btnCarregar);
            var listView = this.FindViewById <ListView>(Resource.Id.ltwItens);

            button.Click += async(sender, e) =>
            {
                var api   = new MaratonaXamarin.Shared.UserApi();
                var users = await api.ListAsync(new Shared.Developer
                {
                    Id    = Guid.NewGuid().ToString(),
                    Name  = "Carlos Eduardo",
                    Email = "*****@*****.**",
                    State = "Rio de Janeiro",
                    City  = "Niterói"
                });

                listView.Adapter = new ArrayAdapter(this,
                                                    Android.Resource.Layout.SimpleListItemSingleChoice,
                                                    users
                                                    .OrderBy(y => y.Name)
                                                    .Select(x => x.Name)
                                                    .ToArray()
                                                    );
            };
        }
Пример #2
0
        public override void ViewDidLoad()
        {
            CurrentPlatform.Init();

            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            this.btnCarregar.TouchUpInside += async(sender, e) =>
            {
                var api   = new MaratonaXamarin.Shared.UserApi();
                var users = await api.ListAsync(new Shared.Developer
                {
                    Id    = Guid.NewGuid().ToString(),
                    Name  = "Carlos Eduardo",
                    Email = "*****@*****.**",
                    State = "Rio de Janeiro",
                    City  = "Niterói"
                });

                lvwItens.Source = new TableViewSource(users.OrderBy(u => u.Name).Select(u => u.Name).ToList());
                lvwItens.ReloadData();
            };
        }