Android public inline fun String.toFloat():在kotlin.text中定义的浮点
我的DestinationCreateActivity.kt中有创建新数据的代码,如何将文本转换为float DestinationCreateActivity.ktAndroid public inline fun String.toFloat():在kotlin.text中定义的浮点,android,kotlin,Android,Kotlin,我的DestinationCreateActivity.kt中有创建新数据的代码,如何将文本转换为float DestinationCreateActivity.kt newDestination.amount = amount.text.toFloat() 这是我的活动\u destiny\u create.xml <EditText android:id="@+id/amount" android:layout_width=&qu
newDestination.amount = amount.text.toFloat()
这是我的活动\u destiny\u create.xml
<EditText
android:id="@+id/amount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Amount"
android:imeOptions="actionUnspecified"/>
这就是错误所在
此处为
金额。文本
不是字符串
,而是其字符序列
。因此,您应该将其转换为String
,然后再转换为Float
:
amount.text.toString().toFloat()
什么问题here@ShaluTDtoFloat不工作或我的代码中有东西丢失或出错请检查图像,先生。
amount.text.toString().toFloat()