Editable text to string

Android

Android Problem Overview


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

Android Solutions


Solution 1 - Android

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

Solution 2 - Android

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(); 

Solution 3 - Android

This code work correctly only when u put into button click because at that time user put values into editable text and then when user clicks button it fetch the data and convert into string

EditText dob=(EditText)findviewbyid(R.id.edit_id);
String  str=dob.getText().toString();

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBIBEKRBARALView Question on Stackoverflow
Solution 1 - AndroidAlex NtousiasView Answer on Stackoverflow
Solution 2 - AndroidJeremy LoganView Answer on Stackoverflow
Solution 3 - AndroiditechDroidView Answer on Stackoverflow