Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
208 views
in Technique[技术] by (71.8m points)

java - Android How can I Convert a String to a Editable

We all know we can setText(String) to an editText box but if you want to get an editable variable from a string variable how do you do this?

For Temp I made an invisible editText box to set to then get from which turns the string into editable.

re: for my own reference String again = editablevariable.getText().toString()

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As you probably found out, Editable is an interface so you cannot call new Editable().
However an Editable is nothing more than a String with Spannables, so use SpannableStringBuilder:

Editable editable = new SpannableStringBuilder("Pass a string here");

If you only want to change the Spannables, never the text itself, you can use a basic SpannableString.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...