There is an EditText sum entry field with the type "numberDecimal" .
The problem is that after the comma you can put a lot of numbers, but I need no more than 2 (a penny).
How to set the condition that after the comma was not more than 2 characters?
UPD: While there are no imputed answers, he picked himself and did the following:
etSumm.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View view, int i, KeyEvent keyEvent) { //Переменная результата Boolean res = false; //Считываем что находится в EditText String str = etSumm.getText().toString(); //Узнаем какой символ был нажат char c = keyEvent.getDisplayLabel(); //Преобразуем символ в строку, для сравнения String sc = String.valueOf(c); //Если нажата точка и она не первая в строке - разрешаем поставить if (sc.equals(".") && str.length() > 0 ){ res = false; }//Если точки нет и входящий символ не точка - разрешаем поставить else if (str.indexOf(".") == -1 && !sc.equals(".")) { res = false; }//Если точка не первый символ и после нее не больше 2 символов - разрешаем ввод else if ((str.indexOf(".") > 0) && (str.lastIndexOf(".") >= str.length() - 2)) { res = false; } else {//В остальных случаях - запрещаем ввод res = true; } return res; } }); Perhaps there is some more humane method proposed by Google? Very surprised that there is no type of clavus for entering money, or is there? )