Hi I'm working on a application which asks for OTP when user want to reset his password for which I need a text like the one in attached Image... What I thought to proceed with is individual text for each of the letter, All of them arranged in linear layout of horizontal orientation with some margin... and max length as 1 so only one letter can be entered in each editText... Is that a right Approach?? Any Suggestions??
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
using DataBinding layout:
These are some of the links that might help. You can customize it as per your requirement.
This link is a step by step tutorial on how you can create pin entry UI for yourself. https://medium.com/@ali.muzaffar/building-a-pinentryedittext-in-android-5f2eddcae5d3#.ldp03yky7
PinEntry android Library https://github.com/Philio/PinEntryView
You can subclass a TextWatcher and implement your own logic.
The below solution takes into consideration:
Auto focusing to the next edit text on entering one digit of OTP in the focussed edit text.
Auto focusing to the previous edit text on deleting one digit of OTP in the focussed edit text.
The combination of work in onTextChanged() and afterTextChanged() helps in achieving the same.
I implemented the following code based on other answers.
I wanted this code to be very simple, optimized and understandable for changes.
Don't use
android:maxLength="1"
in your xml.i made a generic TextWatcher for 6 digit OTP:
You can add this textWatcher to all your edit texts like this :