I am using this library to format the text as user is typing. I have an EditText
where user types in money. I want to achieve the following behavior as user types:
User input -> Result in EditText
1 -> 1 dollars
10 -> 10 dollars
100 -> 100 dollars
1000 -> 1 000 dollars
However, what I got is that:
1 -> 1 dollars
10 -> 10 dollars
100 -> 100 dollars
1000 -> 100 0 dollars
val mask = MaskedTextChangedListener(
"[000] [000] [000] dollars",
false,
etAmount,
object : TextWatcher {
override fun afterTextChanged(s: Editable?) { }
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
},
null
)
etAmount.addTextChangedListener(mask)
The documentation is not very clear on how to achieve this and I am stuck on this issue. Any suggestions would be greatly appreciated.
Library author here.
We've got a wiki page describing masks for texts with right-to-left alignment; this page includes a case similar to yours.
In short, try configuring your listener like this:
mask.rightToLeft = true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.