开发者

Editable text to string

开发者 https://www.devze.com 2022-12-19 22:38 出处:网络
How can I convert editable text into string in And开发者_StackOverflow社区roid ? Any solution?If I understand correctly, you want to get the String of an Editable object, right? If yes, try using toSt

How can I convert editable text into string in And开发者_StackOverflow社区roid ? Any solution?


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


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


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号