在 edittext 中设置文本时出错

发布于 2024-12-29 06:09:27 字数 273 浏览 3 评论 0原文

我设置了两个编辑文本字段和一个按钮。这个想法是如果我输入任何内容 在其中一个文本字段中,按下按钮,必须在文本字段中设置确切的值 其他领域。这是我的代码。

  rf1.setText("" + rf2);

但是当我运行程序时(输入 24,按下按钮),另一个文本字段中会显示一条奇怪的消息:

“android.widget.EditText......废话。

有什么想法吗??

I've set up two edittext fields and a button. The idea is if I key in anything
in one of the text fields, press the button the exact value must be set in the
other field. Here 's my code.

  rf1.setText("" + rf2);

But when I run the program (input say 24, press button) a strange message is displyed in the other text field saying

"android.widget.EditText.....blah.

Any ideas anyone ??

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

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

发布评论

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

评论(1

别再吹冷风 2025-01-05 06:09:28

假设 rf1 和 rf2 是您的 EditText 字段,则在设置文本之前不会将其转换为字符串。

试试这个:

String strRf2 = rf2.getText().toString();

然后使用 setText()

rf1.setText("" + strRf2);

Assuming that rf1 and rf2 are your EditText fields, you are not converting it to a string before setting the text.

Try this:

String strRf2 = rf2.getText().toString();

Then use setText()

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