Roman Truba
Roman Truba

Reputation: 4401

Is there any way to replace text in EditText with spannable, but save value?

What I have: user see EditText and can input some numbers into it, or push button and some numbers will be insert into EditText. The problem is to replace the numbers with text, but save numeric value.

For example, after press button, application can insert text 123, but this text should be replaced to "For all". I don't wanna just insert text, because Editable.toString() will return that text. I can't insert images like badges, because application is multilanguage, and repainting labels for each language will be too long.

So, can I replace 123 with spannable string "For all", and when user press backspace he will have 12? If it possible, how to do such thing?

Thank you!

Upvotes: 2

Views: 1037

Answers (1)

g00dy
g00dy

Reputation: 6778

Let's start with that. I don't know why you need this strange "translation", but anyway - some questions here: If I'm to input "123" as numbers and I manage to see "For all" as text, when backspacing (in order to receive "12", with the "3" removed) how can I know what I typed? Can't this be done in two EditText fields, the one for Input and the other for Output? Is it only "123" that you want to be "translated" to "For All" or you have some rules for "translating" numbers to text?

Upvotes: 1

Related Questions