public async override void OnStart() { base.OnStart(); LayoutInflater inflater = Activity.GetSystemService(Context.LayoutInflaterService) as LayoutInflater; if (inflater != null) { DateTime lastDataRefresh = await Model.RefreshData(); RefreshTimestamp.Text = lastDataRefresh.ToLongTimeString(); ProductsCollection = Model.GetProducts(); Adapter = new Products.Model.ProductsListAdapter(ProductsCollection, inflater); ProductsList.Adapter = Adapter; ProductsList.ItemClick += OnProductClick; } // Timer for adding new dummy product // Just for testing purpose Timer timer = new Timer(1 * 1000); timer.Elapsed += (object sender, ElapsedEventArgs e) => { Activity.RunOnUiThread(() => { ProductsCollection.Add(new ProductEntity { Name = $"Product Timer {e.SignalTime}", Price = 100 }); }); }; timer.AutoReset = true; timer.Start(); Timer timer2 = new Timer(5 * 1000); timer2.Elapsed += (object sender, ElapsedEventArgs e) => { Activity.RunOnUiThread(() => { int i = 0; foreach (ProductEntity product in ProductsCollection) { product.Name = $"Test {i + 1}"; i++; } }); }; timer2.Start(); }
public override void OnStart() { base.OnStart(); LayoutInflater inflater = Activity.GetSystemService(Context.LayoutInflaterService) as LayoutInflater; if (inflater != null) { Adapter = new Products.Model.ProductsListAdapter(Model.GetProducts(), inflater); ProductsList.Adapter = Adapter; ProductsList.ItemClick += OnProductClick; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView (Resource.Layout.Products); // UI elements ProductsList = FindViewById<ListView> (Resource.Id.productsList); // Model Model = new Model.ProductsModel(); // Set data to ListView ArrayAdapter<Model.Products.ProductEntity> stringAdapter = new ArrayAdapter<Model.Products.ProductEntity>(this, Android.Resource.Layout.SimpleListItem1, Model.GetProducts()); ProductsList.Adapter = stringAdapter; }
public async override void OnStart() { base.OnStart(); LayoutInflater inflater = Activity.GetSystemService(Context.LayoutInflaterService) as LayoutInflater; if (inflater != null) { DateTime lastDataRefresh = await Model.RefreshData(); RefreshTimestamp.Text = lastDataRefresh.ToLongTimeString(); Adapter = new Products.Model.ProductsListAdapter(Model.GetProducts(), inflater); ProductsList.Adapter = Adapter; ProductsList.ItemClick += OnProductClick; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Products); // UI elements ProductsList = FindViewById <ListView> (Resource.Id.productsList); // Model Model = new Model.ProductsModel(); // Set data to ListView ArrayAdapter <Model.Products.ProductEntity> stringAdapter = new ArrayAdapter <Model.Products.ProductEntity>(this, Android.Resource.Layout.SimpleListItem1, Model.GetProducts()); ProductsList.Adapter = stringAdapter; }