In my AndroidManifest.xml file, I have the following definition for the EditText

    <EditText
        android:id="@+id/dob_aob"
        android:layout_width="match_parent"
        android:layout_height="@dimen/edtxt_height"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="0dp"
        android:gravity="center_vertical"
        android:padding="10dp"
        android:background="#eed0d0"
        android:textSize="@dimen/edtxt_font_size"
        android:textColor="@android:color/black"
        android:textCursorDrawable="@null"
        android:imeOptions="actionGo"
        android:inputType="numbers"
        android:digits="*+-0123456789"
        android:ems="10"/>

I.e.: The user enters an integer between 0 through 9 and the multiplication, addition, and subtraction symbols.

The following came up on my phone:
http://imgur.com/YP6dXtU

In a different program, I saw the following keyboard come up:
http://imgur.com/QXAPnOV

May someone, tell me the precise name of the "inputType" of the latter?

My os is: Android 4.4.3

Dani AI

Generated

Short answer: that layout is the phone-style keypad — the Android input type that requests it is phone (i.e. android:inputType="phone"). The on‑screen appearance you saw is produced by the active soft keyboard (the IME), so different devices/keyboards can show different arrangements for the same inputType. As showed and as suggested, it’s an IME/layout difference rather than a new XML attribute. (developer.android.com)

A couple of clarifications that commonly cause confusion: numbers (plural) is not a documented inputType value. Android exposes classes like number (and variations such as numberDecimal, numberSigned) and phone for telephone-style input; use the one that best matches the UI you want. The android:digits attribute can restrict which characters are accepted, but it doesn’t guarantee the IME will display particular keys. (developer.android.com)

If the goal is to show a telephone keypad (with * / # and numeric keys) use inputType="phone". If you must absolutely enforce a small allowed set of characters regardless of keyboard, validate on entry (InputFilter) or in your text handling code — treat inputType and digits as hints, not as enforcement. IMEs and OEM keyboards vary, so test on representative devices. (developer.android.com)

Practical enforcement example (Java InputFilter — attach with editText.setFilters(...)):

InputFilter filter = new InputFilter() {
  @Override
  public CharSequence filter(CharSequence src, int start, int end,
                             Spanned dest, int dstart, int dend) {
    String allowed = "0123456789+-*";
    for (int i = start; i < end; i++) {
      if (allowed.indexOf(src.charAt(i)) == -1) return "";
    }
    return null;
  }
};
editText.setFilters(new InputFilter[]{filter});

Use inputType="phone" for the phone keypad and add an InputFilter (or server/client validation) to guarantee accepted characters. (developer.android.com)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.