在Android EditText中实现ATM数值输入行为 [英] Implementing ATM Numeric input behaviour in Android EditText

查看:75
本文介绍了在Android EditText中实现ATM数值输入行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Android中使用EditText实现以下输入行为.是否有一个现有的库可以实现此行为,否则,逻辑将是怎样的?在ATM机上也可以看到这种行为.

How can I implement the following input behaviour using EditText in Android. Is there a existing library to implement this behaviour or if else, what would the logic be like? This behaviour can be seen on ATM machines as well.

以下是一个gif,可以在Android应用中演示此行为:

Here's a gif that demonstrates this behaviour in an Android app:

如所观察到的,输入从最后一位开始,并在附加必要的逗号和小数点分隔(2个小数点)的同时继续向左移动.我找不到任何实现此行为的库.

As observed, the input starts with the last digit and proceeds to the left while appending necessary commas and decimal separation (2 decimals). I couldn't find any library that implements this behaviour.

您可以通过现有的实现或库为我指明正确的方向吗?

Can you point me in the right direction with an existing implementation or a library?

推荐答案

我解决了这个问题,并根据Subhechhu Khanal到已解决线程的链接构建了一个自定义库.任何需要此行为的人都可以使用自定义库并根据需要对其进行自定义.

I resolved this and built a custom library based on Subhechhu Khanal's link to a resolved thread. Anyone who needs this behaviour can use the custom library and customise it as required.

ATM-EditText库: https://github.com/dinukapj/ATM-EditText

ATM-EditText Library: https://github.com/dinukapj/ATM-EditText

我鼓励社区改善这个图书馆.谢谢!

I encourage the community to make this library better. Thanks!

这篇关于在Android EditText中实现ATM数值输入行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆