TextInputEditText не работает с inputType number|numberDecimal

TextInputEditText не хочет работать с цифровой клавиатурой. Если установить параметр inputType="text", то данные спокойно вводятся в поле. Как только ставлю inputType="number" клавиатура перестает реагировать на ввод числовых значений, так же на любые другие клавиши, за исключением тех, нажатие которых я обрабатываю сам в TextView.OnKeyListener()

<com.google.android.material.textfield.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@+id/textView2" android:layout_marginTop="64dp"
        app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"
        android:singleLine="false" android:id="@+id/textInputEditText" android:inputType="number|numberDecimal"
        android:gravity="center_horizontal|center_vertical"/>

public class MainActivity extends AppCompatActivity {
int score = 0;
int r1;
int r2;
TextInputEditText input;
TextView primer;
TextView textview;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    r1 = (int) Math.round(Math.random()*77+23);
    r2 = (int) Math.round(Math.random()*77+23);
    input = (TextInputEditText) findViewById(R.id.textInputEditText);
    input.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    primer = (TextView) findViewById(R.id.textView2);
    textview = (TextView) findViewById(R.id.textView);
    textview.setText("Ваш текущий счёт: " + score);
    primer.setText(r1 + " • " + r2 + " = ");
    input.setOnKeyListener(new TextView.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            int x = 0;
            if ((event.getAction() == ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                try {
                    x = Integer.parseInt(input.getText().toString());
                    if (x == r1 * r2) {
                        score += 1;
                        textview.setText("Ваш текущий счёт: " + score);
                        input.setText("");
                        r1 = (int) Math.round(Math.random()*77+23);
                        r2 = (int) Math.round(Math.random()*77+23);
                        primer.setText(r1 + " • " + r2 + " = ");
                    }
                    else {textview.setText("Вы ввели неверный ответ");
                    input.setText("");}
                } catch (NumberFormatException e) {
                    textview.setText("Вы ввели неверный ответ");
                    input.setText("");
                }
            }
            return true;
        }
    });

}

}


Ответы (0 шт):