2

I have an editText that has a limit of 4 characters

I want to add a place holder in all the empty characters

Is similar to a password input

○ for empty characters and ● for already taken

Examples:
Pin is 112 => Result in EditText ●●●○
Pin: 12 => EditText ●●○○
Pin: 1234 => EditText ●●●●

  • why not add a `addTextChangedListener` and change your ui based on char change ? – makkhay gurung Aug 22 '19 at 18:09
  • @makkhaygurung it's not entirely that easy, because you also have to keep track of the ACTUAL input too – a_local_nobody Aug 22 '19 at 19:40
  • Best way in my opinion is to use Custom View : https://developer.android.com/guide/topics/ui/custom-components – Syed Ahmed Jamil Aug 23 '19 at 08:47
  • I am not the most experienced Android developper, but I have been trying to fiddle this for a few hours now and it is actually hard. Using addTextChangedListener makes it very hard to handle selection focus and keep track of the actual text – Olivier Melançon Aug 23 '19 at 14:10

1 Answers1

0

I ended doing a simple custom view that does what I wanted. Is a little outdated but can be tweaked easily.

https://github.com/waveduke/PinView

I hope it helps anyone that has the same problem :)