How to show the numeric keypad

I read several other posts and using input.setInputType(TYPE_NUMBER_FLAG_DECIMAL); does open the keyboard but its not the numeric keyboard

Is there a trick to this?

  • iOS / Android cross platform development
  • Error retrieving parent for item: No resource found that matches the given name after upgrading to AppCompat v23
  • Android 7.0 (Nougat) Doze Mode Stops Web Service
  • Multidex installation failure
  • Android Studio after updating to build tools 19.1.0
  • Is there any way to enable scrollbars for RecyclerView in code?
  • Getting Can't find common super class of after enabling Pro-guard
  • Get the distance between two locations in android?
  • How to move and rename a project in android studio?
  • A way to get unlock event in android?
  • Google Maps API v2 SupportMapFragment inside ScrollView - users cannot scroll the map vertically
  • Calling DialogFragment's show() from within onRequestPermissionsResult() causes IllegalStateException in Marshmallow
  • 4 Solutions collect form web for “How to show the numeric keypad”

    give
    android:inputType="number" inside your xml file

    Edit: “Number” does not work, changed to “number” (lowercase N)

    a) in xml

    android:numeric="decimal"
    

    b) in code

    EditText editView = new EditText(this);
    editView.setKeyListener(new DigitsKeyListener());
    

    In your xml, you have to do this:

    android:inputType="Number"
    

    In your code, do:

    editText.requestFocus();
    

    Then:

    InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
    

    Took me many days to figure this out. I even tried editText.performClick(); Not working.

    To pop up a numeric keyboard on start of the activity i used following steps:

    Created edit text field in layout as:

     <EditText
            ...
            android:inputType="number"    
            ...  />
    

    In function onCreate() show soft keyboard

    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
    

    Most important is to give focus to edit text in onResume method.

        @Override
        public void onResume() {
            super.onResume();
            editText.setFocusableInTouchMode(true);
            editText.requestFocus();
        }
    
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.