所以我有一些textViews
他们的输入是数字,但为了不易出错,我想将其替换为numberPickers
.
我做了什么
TextViews
工作NumberPickers
工作- 任何数学和计算工作
我需要什么:
更换输入法
这就是我的
textViews
when { time.text.isEmpty() && (distance.text.isNotEmpty() && pace.text.isNotEmpty()) -> calculatePace(null, distance.text.toString().toDouble(), pace.text.toString()) distance.text.isEmpty() && (time.text.isNotEmpty() && pace.text.isNotEmpty()) -> calculatePace(time.text.toString(), null, pace.text.toString()) pace.text.isEmpty() && (time.text.isNotEmpty() && distance.text.isNotEmpty()) -> calculatePace(time.text.toString(), distance.text.toString().toDouble(), null) else -> { Toast.makeText(this, "Please check fields", Toast.LENGTH_SHORT).show() } }
这些是我的pickers
:
val pickerMinutes = numberPicker as NumberPicker
val pickerSeconds = numberPickerSeconds as NumberPicker
pickerMinutes.minValue = 0
pickerMinutes.maxValue = 60
pickerMinutes.wrapSelectorWheel = false
pickerMinutes.isEnabled = true
pickerSeconds.minValue = 0
pickerSeconds.maxValue = 60
pickerSeconds.wrapSelectorWheel = false
pickerSeconds.isEnabled = true
任何帮助将不胜感激
谢谢