ArrayList
val arrayList: MutableList<String> = ArrayList()
arrayList.add("ADVERTISE_TX_POWER_ULTRA_LOW")
arrayList.add("ADVERTISE_TX_POWER_LOW")
arrayList.add("ADVERTISE_TX_POWER_MEDIUM")
arrayList.add("ADVERTISE_TX_POWER_HIGH")
return arrayList
val list = listOf("ADVERTISE_TX_POWER_ULTRA_LOW", "ADVERTISE_TX_POWER_LOW", "ADVERTISE_TX_POWER_MEDIUM", "ADVERTISE_TX_POWER_HIGH")
ArrayAdapter
val arrayAdapter = ArrayAdapter(requireActivity(),
android.R.layout.simple_list_item_1,
list)
Spinner.onItemSelectedListener //multi override method
spinner.onItemSelectedListener = object : OnItemSelectedListener {
override fun onItemSelected(p0: AdapterView<*>?, p1: View?, position: Int, p3: Long) {
Log.d(TAG, "onItemSelected")
}
override fun onNothingSelected(p0: AdapterView<*>?) {
Log.d(TAG, "onNothingSelected")
}
}
ViewModel
private lateinit var viewModel: MainViewModel
viewModel = ViewModelProvider(this,
ViewModelProvider.NewInstanceFactory()).get(MainViewModel::class.java)
|