protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Create new List BeaconList = new List <Beacon>(); eraseSelectedBeacon(); /// Create References DiscoverBeacons = FindViewById <Button>(Resource.Id.btnSim); NumberOfBeacons = FindViewById <TextView>(Resource.Id.txtNumber); DisplayBeacons = FindViewById <Button>(Resource.Id.btnDisplay); BeaconListView = FindViewById <ListView>(Resource.Id.lstBeacons); ProgressBar_Discovery = FindViewById <ProgressBar>(Resource.Id.progressBar_Discovery); adapter = new BeaconListViewAdapter(this, BeaconList); // Assign the Adapter BeaconListView.Adapter = adapter; // ListView Click BeaconListView.OnItemClickListener = this; DisplayBeacons.Click += DisplayBeacons_Click; }
private void MainActivity_onBeaconComplete(object sender, EventArgs e) { if (BeaconList.Count != 0) { DiscoverBeacons.Text = "Display Beacons"; ProgressBar_Discovery.Visibility = Android.Views.ViewStates.Invisible; NumberOfBeacons.Text = BeaconList.Count.ToString(); Console.WriteLine("Setting the Number of Beacons to: " + BeaconList.Count.ToString()); // This is after the text changed - Therefore this means that we just finished Discovering NumberOfBeacons.Text = BeaconList.Count.ToString(); // Refresh the Listview Adapter (Otherwise you wont see the new objects in the Listview) BeaconListView.Adapter = null; //adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, TempList); adapter = new BeaconListViewAdapter(this, BeaconList); BeaconListView.Adapter = adapter; DiscoverBeacons.Text = "Discover Beacons"; } else { NumberOfBeacons.Text = "Error"; } DiscoverBeacons.Enabled = true; return; }