I am using inputType:number for EditText.
But the problem is that when I click on Done Button(Right Mark) present at bottom left of keyboard it opens up Alphanumeric keyboard.
My EDIT TEXT XML Code:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/enter_detail"
android:hint="Enter Detail"
android:padding="20dp"
android:inputType="number"
android:textColorHint="#42a5f5"
android:textColor="#color/title_black"
app:layout_constraintTop_toBottomOf="#id/radio_group"/>
UPDATE
I have found that DATEPICKER with datePickerMode="spinner" is creating issue.
I switched to datePickerMode="calendar" and it solved the problem.
I think there is a problem with the DatePicker widget because when used spinner mode bottom part is incomplete(Please refer to this question to understand this problem: Android: Datepicker bottom part not visbile)
I have created GIF of the video:
How about replacing the inputType with "number|numberDecimal"
android:inputType="number|numberDecimal".
Between the Activity tags in my AndroidManifest.xml I have :
android:windowSoftInputMode = "stateVisible"
So when my activity starts the soft keyboard comes up:
Is there not something I can add to make the phone input keyboard come up instead? Or how would I do it? Thanks.
EDIT
For the sake of clarity to this question I'm adding this 'edit'.
First of all, thanks for all the answers below.
However, my objective is to have no Edittext Visible on the screen, at first. The Phone Input soft keyboard comes up as soon as the activity starts and when the user starts
to type then the Edittext will become visible, with the text being typed.
I tried making the Edittext invisible, and then make it visible when user starts typing, but the problem is an invisible edittext can't have the focus,
So, android:inputType="number" was having no effect. And neither was: edittext.requestFocus(); Because the edittext was invisible.
What I ended up doing eventually was something very simple, setting width and height to 0dp in my xml like :
android:id="#+id/etPhoneNumber"
android:layout_width="0dp"
android:layout_height="0dp"
android:inputType="number" />
That way, the edittext can get focus with
edittext.requestFocus();
as soon as the activity is created, and inputType = "number" is recognised.
The next thing I'll do is increase the size of the edittext as soon as a key is hit on the soft keyboard, so users can see it.
I'll put all this in as an answer so it might be helpful to other users. +1 for the help!
Assuming that you have an EditText in the Activity which you show once your app is started, you can add below XML Attribute to your EditText.
android:inputType="phone"
Check developer docs for other input types in case if you need.
You can add
android:inputType="phone"
or
android:inputType="number"
to your View in your XML layout.
You should have some View in your code where you can give input like EditText or AutoCompleteTextView for changing the type of the keypad.
For example -
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:inputType="phone"
/>
In manifest file set the property in activity,
android:windowSoftInputMode="stateAlwaysVisible"
and then in your xml where your EditText set the property,
android:inputType="number"
first of all take an EditText in your xml
<EditText
android:id="#+id/etPhoneNumber"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="number" />
use this piece of code in the onCreate method of your activity !
EditText etPhoneNumber = (EditText) findViewById(R.id.etPhoneNumber);
etPhoneNumber.requestFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
This works for me very well ! Hope it works for you too !
Let me know if this works ! :)
The objective is to have no Edittext Visible on the screen, at first.
The Phone Input soft keyboard comes up as soon as the activity starts and when the user starts
to type then the Edittext will become visible, with the text being typed.
I tried making the Edittext invisible, and then make it visible when user starts typing, but the problem is an invisible edittext can't have the focus,
So, android:inputType="number" was having no effect. And neither was: edittext.requestFocus(); Because the edittext was invisible.
What I ended up doing eventually was something very simple, setting width and height to 0dp in my xml like :
android:id="#+id/etPhoneNumber"
android:layout_width="0dp"
android:layout_height="0dp"
android:inputType="number" />
That way, the edittext can get focus with
edittext.requestFocus();
as soon as the activity is created, and inputType = "number" is recognised.
The next thing to do now is increase the size of the edittext as soon as a key is hit on the soft keyboard, so users can see it.
I set imeoptions="actionDone" for my EditText in xml and everything works fine on a Medion Lifetab or Nexus 4 (on press "Enter" the softkeyboard disappears).
But I need this to work on a Honeywell Dolphin e70. On this device if I press "Enter" the next EditText gets focus. I already tried to set singleline true but didnt change the behavior.
This is the EditText I use:
<EditText
android:id="#+id/id1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".55"
android:imeOptions="actionDone"
android:inputType="textCapSentences"
android:selectAllOnFocus="true"
android:textSize="#dimen/dimen1" />
Like I said, on other devices it works like intended.. Anyone got an idea for a workaround or where I can start handling this? I definetly dont want to set a keylistener to EVERY damn EditText is the application, that would totaly be an overkill..
thanks
You can see Close/hide the Android Soft Keyboard to hide the keyboard and Android Use Done button on Keyboard to click button to catch the dome button action.
I have one quesiton with me.
I am trying to find the answer but no success.
1-I have one editpasswordfield in which i can give only numeric password.
i did like this
<EditText
android:id="#+id/editText4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="numberPassword"/>
and its showing the keyboard number with text.
but i need the keyboard like this
i tried this
android:inputType="numberPassword|number"
and many possibilities but does not worked for me .
if i try android:inputType="number".It works but my field is password so this does not work its visible to user.
any help.
Try this..
EditText editText = (EditText) findViewById(R.id.editText4);
editText.setInputType(InputType.TYPE_CLASS_NUMBER);
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
Hope this helps....
In my app, I have an EditText. How do I make it doesn't start automatically? Like: once they open the activity it automatically sets the mouse to the EditText and the keyboard gets opened so they type…
Is there anyway I can make it open (the keyboard shows and the user can type) when they clicks on it?
Ok, so from your question i figure out that your EditText is getting focus while starting the activity. You can disable the focus using following command to suppress the keyboard.
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Visit this Close/hide the Android Soft Keyboard
the answer by Lucifer must work. But when i got the same problem, that solution did't work, and someone suggested me this.
add a fake layout as the first element in you parent layout and make it focusable.
Like this:
<ParentLayout
.....
......>
<LinearLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#android:color/transparent"
android:focusable="true"
android:focusableInTouchMode="true" >
</LinearLayout>
......
......
......
</ParentLayout>
This definitely works, but the best solution is:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);