So I have some textViews
that their inputs are numbers, but in order to be less prone to error I want to replace it with numberPickers
.
What I have done
TextViews
workNumberPickers
Work- Any math and calculation works
What I need:
To replace the input method
This is what I have for my
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() } }
These are my 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
Any help would be very appreciated
Thanks