Code example for Spinner

Methods: getAdapter, setSelection

0
        
        if (mDeviceSpinner == null) {
            return; 
        } 
 
        BluetoothDeviceArrayAdapter bluetoothDeviceArrayAdapter = (BluetoothDeviceArrayAdapter) mDeviceSpinner.getAdapter();
         
        boolean exists = false;
        for (int i = 0; i < bluetoothDeviceArrayAdapter.getCount(); i++) {
            BluetoothDeviceView deviceView = bluetoothDeviceArrayAdapter.getItem(i);
             
            if (device.getAddress().equals(deviceView.getAddress())) {
                deviceView.setBluetoothDevice(device);
                exists = true;
                break; 
            } 
        } 
         
        if (!exists) {
            BluetoothDeviceView deviceView = new BluetoothDeviceView(device, spoofMode);
            bluetoothDeviceArrayAdapter.add(deviceView);
            mDeviceSpinner.setSelection(bluetoothDeviceArrayAdapter.getNullPosition());
        } 
    } 
     
}