Android numeric keypad on Click button

In my application, I am trying to display a numeric keypad when a user clicks a button.

When the button is pressed, I move the focus to EditText in my layout using requestFocus (), and then I need to display the numeric keypad so that the user can enter values.

Values ​​will always be numeric, and so I need to show only the numeric keypad.

I'm tired of using this inside my onClick () button, but this does not work.

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

Please provide me some solution.

In addition, my application is designed for an Android tablet that supports 4.0.3.

+4
android buttonclick
Jun 21 '12 at 9:05
source share
2 answers

This object in the EditText property

 android:inputType="phone" (This will displayed phone numeric keypad) 

or

 android:inputType="number" (This will displayed numeric keypad) 

Now you just need to set Focus to your EditText on the click button ..

something like,

 edtNumber = (EditText) findViewById(R.id.number); // Button onClick.... @Override public void onClick(DialogInterface dialog, int which) { edtNumber.requestFocus(); } 
+6
Jun 21 2018-12-12T00:
source share

in an EditText placed below the line.

 android:inputType="number" 
+6
Jun 21 2018-12-12T00:
source share



All Articles