Editable text to string


Question

How can I convert editable text into string in Android ? Any solution?

1
71
7/30/2010 4:30:11 PM

Accepted Answer

If I understand correctly, you want to get the String of an Editable object, right? If yes, try using toString().

145
2/7/2010 6:52:22 AM

Based on this code (which you provided in response to Alex's answer):

Editable newTxt=(Editable)userName1.getText(); 
String newString = newTxt.toString();

It looks like you're trying to get the text out of a TextView or EditText. If that's the case then this should work:

String newString = userName1.getText().toString(); 

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon