Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I show the number keyboard on an EditText in android?

I just basically want to switch to the number pad mode as soon a certain EditText has the focus.

like image 319
Chiwai Chan Avatar asked Jul 13 '09 13:07

Chiwai Chan


People also ask

How do I get the keyboard to show in EditText?

android:windowSoftInputMode="stateAlwaysVisible" -> in manifest File. edittext. requestFocus(); -> in code. This will open soft keyboard on which edit-text has request focus as activity appears.

How can add only numbers in EditText in android?

You can use android:inputType="number" in the XML file. You can specify other values such as numberDecimal as well. Also, you might additionally want to use android:singleLine="true" for a single line Edittext .


2 Answers

You can configure an inputType for your EditText:

<EditText android:inputType="number" ... />
like image 145
Josef Pfleger Avatar answered Sep 18 '22 00:09

Josef Pfleger


To do it in a Java file:

EditText input = new EditText(this); input.setInputType(InputType.TYPE_CLASS_NUMBER); 
like image 41
Dominic Avatar answered Sep 19 '22 00:09

Dominic