TextView到String(TextView to String)

编程入门 行业动态 更新时间:2024-10-28 17:17:01
TextView到String(TextView to String)

我正在尝试将TextView转换为字符串,我不确定我是否正确地使用它,下面是我认为可行的代码,但我不断收到错误。

TextView test1 = (TextView)findViewById(R.id.result1); String testA = test1.getText().toString();

这是正确的方法吗?还是有另一种方法? 任何帮助,将不胜感激。

I'm trying to convert TextView into a string and I'm not sure if I'm going about it the right way, below is the code I thought would work but I keep getting errors.

TextView test1 = (TextView)findViewById(R.id.result1); String testA = test1.getText().toString();

Is this the correct method to do this or is there another way? Any help would be appreciated.

最满意答案

你的代码是正确的。 请注意,只有在调用onCreate并且已设置了contentView才能使用它。

Your code is correct. Beware that it will only work once onCreate has been called and your contentView has been set.

更多推荐

本文发布于:2023-08-06 07:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1445977.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:TextView   String

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!