Exemple #1
0
        public override View GetView(int index, View convertView, ViewGroup parent)
        {
            var view      = activity.LayoutInflater.Inflate(Resource.Layout.MainListItem, parent, false);
            var network   = netList[index];
            var mainTitle = view.FindViewById <TextView>(Resource.Id.textView1);

            mainTitle.Text = netList[index].Name;
            var cardview = view.FindViewById <CardView>(Resource.Id.itemCardView);

            view.FindViewById <TextView>(Resource.Id.panel_count).Text  = network.Panels.ToString();
            view.FindViewById <TextView>(Resource.Id.panel_energy).Text = $"{network.PanelsEnergy.ToString("0.00")} kW";

            view.FindViewById <TextView>(Resource.Id.consumer_count).Text  = network.Consumers.ToString();
            view.FindViewById <TextView>(Resource.Id.consumer_energy).Text = $"{network.ConsumersEnergy.ToString("0.00")} kW";

            cardview.Click += delegate
            {
                activity.StartActivity(NetworkActivity.CreateIntent(activity, netList[index].ID));
            };
            var del = view.FindViewById <Button>(Resource.Id.delete_button);

            del.Click += delegate
            {
                Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(activity);
                alertDialog.SetTitle("Delete network");
                alertDialog.SetMessage("Are you sure you want to delete this network?");
                alertDialog.SetNeutralButton("Yes", async delegate
                {
                    await DeleteNetwork(netList[index]);
                    alertDialog.Dispose();
                });
                alertDialog.SetNegativeButton("No", delegate
                {
                    alertDialog.Dispose();
                });
                alertDialog.Show();
            };
            return(view);
        }