示例#1
0
        private void initalizeMainButtons()
        {
            SetContentView(Resource.Layout.Main);
            _searchButton = FindViewById <Button>(Resource.Id.buttonSearch);
            devicesList   = FindViewById <ListView>(Resource.Id.deviceList);


            DeviceListAdapter listAdapter = new DeviceListAdapter(this, devices);

            devicesList.Adapter = listAdapter;

            _searchButton.Click   += SearchButton_Click;
            devicesList.ItemClick += DevicesList_ItemClick;
        }
示例#2
0
        public void LookForDevices()
        {
            myBluetoothAdapter = BluetoothAdapter.DefaultAdapter;

            if (myBluetoothAdapter == null)
            {
                Toast.MakeText(this, "Nie wykryto adaptera bluetooth", ToastLength.Short).Show();
            }
            else if (!myBluetoothAdapter.IsEnabled)
            {
                Toast.MakeText(this, "Buletooth jest wylaczone", ToastLength.Short).Show();
                var enableBtIntent = new Intent(BluetoothAdapter.ActionRequestEnable);
                StartActivityForResult(enableBtIntent, 2);
            }
            else
            {
                var _devices = myBluetoothAdapter.BondedDevices;
                devices = _devices.ToList();
                DeviceListAdapter listAdapter = new DeviceListAdapter(this, devices);
                devicesList.Adapter = listAdapter;
            }
        }