车载安卓除了基本的kt语言还有哪些是必须掌握的呢?学习门槛有哪些?
在该页面的fragment.kt中,onViewCreated方法内,with(binding){ }代码段内,增加如下代码:
/**
* 滑动选择器绑定数据项功能为:设定温度/设定时间时:
*/
widgetPickerSetTime.let {
// val textList = resources.getStringArray(R.array.model); //从xml文件中读取字符串数组
val textList = listOf<String>("5", "10", "15", "20", "25", "30", "35", "40").toTypedArray() //模式名称数组
it.refreshByNewDisplayedValues(textList) //设置显示内容:字符串数组
it.value = 3 //设置初始值索引号:int
it.setOnValueChangedListener { picker, oldVal, newVal ->
run {
Log.d(TAG, "newVal = $newVal, text = ${textList[newVal]}")
vm.setTime(textList[newVal].toInt()) //设定时间
// vm.setTemp(textList[newVal].toInt()) //设定温度
}
}
}
转换规则下图所示,结合注释文字: