//型号
Class DeviceBT
class DeviceBT(
private val id: Long,
private val name: String,
private val macAddress: String
)
//主要活动:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//Spinner Test
var listDeviceBT = arrayListOf<DeviceBT>()
listDeviceBT.add(BTDeviceModel(1,"Peripherique 1", "00:00:00:00:01" ))
listDeviceBT.add(BTDeviceModel(2,"Peripherique 2", "00:00:00:00:02" ))
listDeviceBT.add(BTDeviceModel(3,"Peripherique 3", "00:00:00:00:03" ))
listDeviceBT.add(BTDeviceModel(4,"Peripherique 4", "00:00:00:00:04" ))
//spinner adapter
val spinnerBTAdapter = ArrayAdapter<DeviceBTDataLight>(this, R.layout.support_simple_spinner_dropdown_item,listDeviceBTLight)
spinnerBTAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item)
spinner_BTAssocied.adapter = spinnerBTAdapter
}
微调器列表不返回文本,返回Adapter.BTDeviceModel@456654e如何获取name的值?感谢的帮助
覆盖DeviceBT类中的toString方法。
override fun toString(): String {
return name
}