DavidPizarro / PinView

A Pin view widget for Android
Apache License 2.0
286 stars 60 forks source link

How to set text for Pinview? #9

Open RuynLe opened 7 years ago

RuynLe commented 7 years ago

Hi David, thanks your for share. I have a string value, I want to set it to pinview. How can I do that?

ananthDev commented 7 years ago

Yeah I made a little hack

public void updateSMSCode(String code) { char[] codeSplit = code.toCharArray(); for (int i = 0; i < otpPin.getChildCount(); i++) { LinearLayout top = (LinearLayout) otpPin.getChildAt(i); if (top != null) {//safe check // LinearLayout pinTitleView = (LinearLayout) top.getChildAt(0); LinearLayout pinView = (LinearLayout) top.getChildAt(1); if (pinView != null) { for (int j = 0; j < otpLength; j++) { EditText pinEdit = (EditText) pinView.getChildAt(j); if (pinEdit != null) { pinEdit.setText(String.valueOf(codeSplit[j])); } } } } } }