I am working an app that display table inputs and a total, i am using a text Watcher to keep truck with changes in the edit text but the issue, when I tried to change inputs the total won't display properly When I erase the input it should be subtracted with the total and when added a new input it should be added with the total.?
var fifthUp = 0
floor5_up.addTextChangedListener(object : TextWatcher {
var a = 0
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
}
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
fifthUp -= a
Log.i("PO TEXT",p0.toString())
total5F_up.text = fifthUp.toString()
a = 0
}
override fun afterTextChanged(p0: Editable?) {
Log.i(TAG, " floor5")
if(p0.toString() != "") {
fifthUp += Integer.parseInt(p0.toString())
total5F_up.text = fifthUp.toString()
a = Integer.parseInt(p0.toString())
findValue( floor5_up, 5,2, 16, 0)
}
}
})