使用EditText进行连续OTP输入 [英] Continuous OTP input with EditText

查看:136
本文介绍了使用EditText进行连续OTP输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此处是4个EditText,用于输入数字密码.我希望它像是,如果第一个EditText用一个数字填充,则焦点应移至下一个EditText,并且也应以相反的方式工作.这样,用户可以从最左边输入密码,也可以从最右边删除密码.

Here is 4 EditText for input a numeric password. I want it to be like, If first EditText is filled by 1 number then, focus should goes to next EditText and should also work same in reverse manner. So that user can keep entering password from Left most and can also erase same way from Right most.

有人可以建议最好的方法是什么吗?

Can someone suggest what can be the best approach to proceed?

推荐答案

您可以使用库 Android PinView/OtpView

或者您可以使用addTextChangedListener添加一个TextWatcher,只要此EditTextView的文本更改,它就会被调用,然后您可以在下一个EditText上调用View.requestFocus()使其聚焦

or you can use addTextChangedListener to add a TextWatcher which is called whenever this EditTextView's text changes then you can call View.requestFocus() on the next EditText to focus it

这篇关于使用EditText进行连续OTP输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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