tags:

views:

992

answers:

2

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
this is my sample code:Editable newTxt=(Editable)userName1.getText();String newString = newTxt.toString();///////////////////////////////////////but this is not working...
RBADS
@bibek - in what way is it not working? What do you get?
Dave Webb
i am getting lots of error only.
RBADS
@bibek - __edit__ your question and put in details of the errors you are receiving.
Dave Webb
dear sir, i want to display string in textview that comes from edittext.
RBADS
finally i got it.i code is like..EditText userName1 = (EditText) findViewById(R.id.profile_name);String newString= (String)u serName1.getText().toString();
RBADS
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
how can i display same text in textView after getting from edittext?
RBADS
TextView.setText. You may find a better way to learn is to spend some time reading the docs and tutorials.
RickNotFred
actually, i just want to display user name from textview thats come from editable text(input text).
RBADS
Finally i solved the problem..EditText userName1 = (EditText)findViewById(R.id.profile_name);String newcommon = (String)userName1.getText().toString();
RBADS