views:

55

answers:

2

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

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

Thanks!

+1  A: 
TextView theFact = (TextView) findViewById(R.id.theFact);
String shareFact = theFact.getText().toString();
Tyler
Thanks... again! You answered my last question too!
Keenan Thompson
You're welcome! Have fun programming in Android!
Tyler
A: 

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

String sharedFact = theFact.getText().toString();
kiki
This is the exact same thing I posted...
Tyler
@Tyler: Sorry, I hadn't seen your post ...
kiki