How can I convert editable text into string in Android ? Any solution?
+3
A:
If I understand correctly, you want to get the String of an Editable object, right? If yes, try using toString()
.
Alex
2010-02-07 06:52:22
this is my sample code:Editable newTxt=(Editable)userName1.getText();String newString = newTxt.toString();///////////////////////////////////////but this is not working...
RBADS
2010-02-07 07:03:02
@bibek - in what way is it not working? What do you get?
Dave Webb
2010-02-07 07:18:03
i am getting lots of error only.
RBADS
2010-02-07 07:32:42
@bibek - __edit__ your question and put in details of the errors you are receiving.
Dave Webb
2010-02-07 08:55:43
dear sir, i want to display string in textview that comes from edittext.
RBADS
2010-02-07 09:14:56
finally i got it.i code is like..EditText userName1 = (EditText) findViewById(R.id.profile_name);String newString= (String)u serName1.getText().toString();
RBADS
2010-02-08 07:19:03
A:
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();
fiXedd
2010-02-07 08:20:54
TextView.setText. You may find a better way to learn is to spend some time reading the docs and tutorials.
RickNotFred
2010-02-07 13:20:01
actually, i just want to display user name from textview thats come from editable text(input text).
RBADS
2010-02-08 05:36:19
Finally i solved the problem..EditText userName1 = (EditText)findViewById(R.id.profile_name);String newcommon = (String)userName1.getText().toString();
RBADS
2010-02-08 07:20:00