Code example for DigitsKeyListener

0
        super(context, prompt);
 
        mAnswer.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED);
 
        // only allows numbers and no periods 
        mAnswer.setKeyListener(new DigitsKeyListener(true, false));
 
        // ints can only hold 2,147,483,648. we allow 999,999,999 
        InputFilter[] fa = new InputFilter[1];
        fa[0] = new InputFilter.LengthFilter(9);
        mAnswer.setFilters(fa);
 
        Integer i = getIntegerAnswerValue();
 
        if (i != null) {
            mAnswer.setText(i.toString());
        } 
    } 
 
 
Experience pair programming with AI  Get Codota for Java