Stack Exchange
Android/Kotlin: show a list of paired bluetooth devices
I need to ask the user to select a paired Bluetooth device.
I need to do this twice:

in a modal dialogue in the case when no adapter has even been selected before, and
on my settings screen.

This is is in my MainActivity.kt for (1).
    fun showDeviceSelector() {
        val btManager: BluetoothManager = getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager;
        val btAdapter: BluetoothAdapter = btManager.getAdapter();
        val pairedDevices: Set<BluetoothDevice>? = btAdapter.bondedDevices;
        // (There is one.)

        val cs: Array<CharSequence> = pairedDevices.map { z -> z.name }.toTypedArray()
        var deviceName: String = ""

        val ab = AlertDialog.Builder(this);
        ab.setTitle("Select device");
        ab.setIcon(android.R.drawable.ic_dialog_alert);
        ab.setPositiveButton("Select") { dialogueInterface, which ->
            btConnect(deviceName);
        };
        ab.setNeutralButton("Cancel") { dialogueInterface, which ->
            Toast.makeText(
                applicationContext,
                "No Bluetooth adapter selected.",
                Toast.LENGTH_LONG
            ).show()
        };
        ab.setItems(cs) { dialog, which -> deviceName = cs[which].toString() };
        val a = ab.create();
        a.setCancelable(false);
        a.show();
    }

It shows a dialogue, but no dropdown. Why?

(Sorry it's not a screenshot, I can't get the emulator to work so I'm using a real device.)
For (2) any pointers would be greatly appreciated -- I'm new to Android but have 15 years experience with C#/SQL etc. and I'm finding it exceptionally difficult.)

The problem is that the list item text is also black.
This is supposed to be overridden using
<item name="android:textColorHint">@color/text</item>

however, typically in Android development, this is not working.
