Wednesday, February 9, 2011

How to retrieve the String from EditText

The getText() method of EditText return a object of Editable, not String. In order to retrieve the text of EditText, toString() of Editable can be used.

 EditText myEditText = (EditText)findViewById(;
String stringEditText = myEditText.getText().toString();


Shariner said...

EditText input = (EditText) findViewById(;

The app crashes with this code.

Anonymous said...

You forgot the layout from where the Text should read.

try this:

EditText input = (EditText) layout.findViewById(;