如何在Kotlin中实现对Integer数据类型的SetText?

发布于 2025-02-12 01:11:57 字数 359 浏览 1 评论 0原文

我想从具有整数typedata的Edittext设置数据。如果是字符串,我们可以制作SEATAKE,但是我们如何在Integer上实现它?

警告是否

可以使用所提供的参数调用以下功能。 com.google.android.material.textfield.textinputeDittext中定义的setText(charsequence!) com.google.android.material.textfield.textinputeDittext中定义的setText(int)

I want to set data from my editText which has integer typedata. if it is string, we can make setTake, but how we can implement it at integer?

The warning is

None of the following functions can be called with the arguments supplied.
setText(CharSequence!) defined in com.google.android.material.textfield.TextInputEditText
setText(Int) defined in com.google.android.material.textfield.TextInputEditText

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离线来电— 2025-02-19 01:11:57

您的代码显示数据是类型userdto。我不知道该类是什么样的,但是它具有称为Phonenumber的字段。这就是您传递给setText()的内容。我无法判断哪种类型phonenumber是因为您还没有向我们展示userdto类,但是该错误告诉我们它既不是int NOR CharSequence,它需要是。您可以尝试这样做才能使它起作用

binding.etPhone.setText(data.phoneNumber.toString())

Your code shows data is of type UserDto. I don't know what that class looks like but it has a field called phoneNumber. This is what you are passing to setText(). I can't tell what type this phoneNumber is because you haven't shown us your UserDto class but the error tells us that it's neither an Int nor CharSequence, which it needs to be. You can try to do this maybe to make it work

binding.etPhone.setText(data.phoneNumber.toString())
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文