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.
更多推荐
发布评论