'How to add extra numbers in textbox automatically

i am trying to make a textbox that has its limit of 32 characters.

If someone enters value like 1234 the program must add 26 Zeros infront example

0000...1234

I have made the limit for 32 characters in xml

android:maxLength="32"


Solution 1:[1]

public String appendChars(String string) {

    int expectedSize = 32;
    // 32 zeros string
    String zeros = "00000000000000000000000000000000";
    int inputLength = string.length();

    // append and return
    if (inputLength < expectedSize) {
        string = zeros.substring(0, expectedSize - inputLength) + string;
    }

    return string;

}

can do something like this

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Karamveer Gahlot