Convert TextView to String (view) Android

I have an object in the main.xml layout file called thefact, which is a TextView. I also have a line called sharefact. I want to save the text in a TextView to a sharefact line. I cant:

sharefact = thefact 

Or something like that because he would like me to convert sharefact into a text representation.

Thanks!

+6
android string textview
source share
2 answers

Retrieving text from a TextView returns a CharSequence . To convert CharSequence to String use the toString() function.

 String sharedFact = theFact.getText().toString(); 
+29
source share
 TextView theFact = (TextView) findViewById(R.id.theFact); String shareFact = theFact.getText().toString(); 
+29
source share

All Articles