Как предотвратить переход чисел в научные обозначения в моем TextView? ⇐ Android
Как предотвратить переход чисел в научные обозначения в моем TextView?
Я делаю калькулятор. Когда я добавляю слишком много символов, дисплей автоматически получает эту научную нотацию. < /P>
Как это предотвратить? if ((answer == null)) {
answer = 0.0
} else {
answer = (answer * 10) + digit
}
answerEditText.setText(checkLast2Digits(answer.toDouble().toString()))
}
// removes the .0 from the end of the string
private fun checkLast2Digits(answerText: String): String {
val checkLast2Digits = answerText.takeLast(2)
if (checkLast2Digits.equals(".0")) {
return answerText.toString().take(answerText.toString().length - 2)
} else {
return answerText.toString()
}
}
Подробнее здесь: https://stackoverflow.com/questions/623 ... y-textview
Я делаю калькулятор. Когда я добавляю слишком много символов, дисплей автоматически получает эту научную нотацию. < /P>
Как это предотвратить? if ((answer == null)) {
answer = 0.0
} else {
answer = (answer * 10) + digit
}
answerEditText.setText(checkLast2Digits(answer.toDouble().toString()))
}
// removes the .0 from the end of the string
private fun checkLast2Digits(answerText: String): String {
val checkLast2Digits = answerText.takeLast(2)
if (checkLast2Digits.equals(".0")) {
return answerText.toString().take(answerText.toString().length - 2)
} else {
return answerText.toString()
}
}
Подробнее здесь: https://stackoverflow.com/questions/623 ... y-textview
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение