(种)转换的TextView为String的Andr​​oid [英] Converting TextView to String (kind of) Android

查看:253
本文介绍了(种)转换的TextView为String的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的main.xml布局文件的对象称为thefact是TextView的。我也有一个名为sharefact字符串。我想保存在TextView中进入sharefact字符串文本内容。我不能做的:

I have an object on my main.xml layout file called thefact that is TextView. I also have a string called sharefact. I want to save what text is in the TextView into the sharefact string. I can't do:

sharefact = thefact

或者什么类似,因为这会要我转换sharefact成一个TextView。

Or anything similar to that because it would want me to convert sharefact into a textview.

谢谢!

推荐答案

这是一个TextView Geeting文本返回的CharSequence。要转换的CharSequence为String,的toString()函数。

Geeting text from a TextView returns CharSequence. To convert CharSequence to String, toString() function is used.

String sharedFact = theFact.getText().toString();

这篇关于(种)转换的TextView为String的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆