简体   繁体   English

将 EditText 转换为 integer (INT)

[英]Transform a EditText in to a integer (INT)

        var distanta = findViewById<EditText>(android.R.id.input)
        km = seekBar.progress
        km = km / 60
        km2 = distanta / km
       textView2.setText(km2).toString()

Project Link: https://drive.google.com/file/d/1s6Pi1kmC1oRmMqf0yJjtV1fAxiDuOr03/view?usp=sharing项目链接: https://drive.google.com/file/d/1s6Pi1kmC1oRmMqf0yJjtV1fAxiDuOr03/view?usp=sharing

Unresolved reference.未解决的参考。 None of the following candidates is applicable because of receiver type mismatch: public inline operator fun BigDecimal.div(other: BigDecimal): BigDecimal defined in kotlin public inline operator fun BigInteger.div(other: BigInteger): BigInteger defined in kotlin由于接收器类型不匹配,以下候选均不适用: public inline operator fun BigDecimal.div(other: BigDecimal): BigDecimal defined in kotlin public inline operator fun BigInteger.div(other: BigInteger): BigInteger defined in kotlin

Try this that may help you试试这个可能对你有帮助

var distanta = findViewById<EditText>(android.R.id.input)
km = seekBar.progress
km = km / 60
km2 = (distanta.text?.toString()?.toInt() ?: 0) / km
textView2.setText(km2.toString())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM