Aju
Aju

Reputation: 4599

How to show first 12 digits to asterisk and last 4 as digits

I have EditText to enter credit card number. I just want to secure first 12 digits and last 4 digits as normal. There should be spaces in between as well. Like the image below:

enter image description here

And card numbers should be extractable from the EditText ie, if editText.getText() should return the whole card number. Please help on this.

Upvotes: 1

Views: 2440

Answers (1)

mmuzahid
mmuzahid

Reputation: 2280

You could try something like that:

String text = editText.getText();
String star = "**** **** **** " + text.subString(text.length() - 4);

Upvotes: 2

Related Questions