My question is simple: I want to show a NumberPad keyboard on my android app without text preview and "Done" button. Just like the keypad that is shown on WhatsApp when user submits his phone number.
I hope the answer would be a simple one too! :)
You should try with textNoSuggestions
android:inputType="textNoSuggestions"
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:inputType="numberPassword"
android:maxLength="10"
android:maxLines="1"
android:padding="10dp"
android:singleLine="true"
android:textColor="#android:color/black" />
android:inputType="numberPassword"
Related
I'm making an APP and want to change the keyboard "Line Break" key into a "Done" key, But I cant use the android:signleLine="true" (seen here: Done key not showing up on keyboard) because the EditText isn't the last EditText in my code.
What could I use/do instead?
Thanks.
Edit
Here is my code:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:width="40dp"
android:maxLength="1"
android:lines="1"
android:textStyle="bold"
android:inputType="textCapCharacters|textFilter"
android:digits="ABCDEFGHIJKLMNOPQRSTUVXYZ"
android:textAlignment="center"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"/>
You can use to set the keyboard action button imeOptions
<EditText
android:id="#+id/search"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/search_hint"
android:inputType="text"
android:imeOptions="actionDone" />
Read more about imeOptions here
You will also have to remove the line
android:digits="ABC..."
as imeOptions do not work well with this.
You can Try this.
By XML
android:imeOptions="actionDone"
By Java
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
this may helps you.
I have few EditText in a same screen. Next soft key button is not there. Enter soft key is there but, it was not going to next EditText whenever I am pressing on that button. And after last EditText reached, I want to hide the soft keyboard. What should I do to achieve that. I found many questions and solution in stackoverflow. Nothing working for me.
Edittext Code:
<EditText
android:id="#+id/vehicle_number"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:imeOptions="flagNoExtractUi|actionNext|actionGo|actionDone"
android:paddingLeft="5dp"
android:textSize="25dp"
android:maxLength="12"
android:hint="GA-00-A0000"
android:digits="1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ-"
android:nextFocusForward="#+id/vehicle_color"
android:inputType="textCapCharacters"
android:background="#drawable/edittext_rect_yellow_border" />
Tried java code also,
vehicle_number.setNextFocusDownId(R.id.vehicle_color);
I fixed myself. The solution is below. Now the 'Next' soft key displaying.
Removed
android:inputType="textCapCharacters"
Added
android:maxLines="1"
android:singleLine="true"
For Capital Characters
vehicle_number.setInputType(InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);
Solution
<EditText
android:id="#+id/vehicle_number"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:imeOptions="flagNoExtractUi"
android:paddingLeft="5dp"
android:textSize="25dp"
android:maxLength="12"
android:hint="GA-00-A0000"
android:maxLines="1"
android:singleLine="true"
android:digits="1234567890qwertyuioplkjhgfdsazxcvbnm-"
android:background="#drawable/edittext_rect_yellow_border" />
I am defining the EditText as below. I want the Done button to appear in the soft keyboard but I am getting Return button instead.
<EditText
android:id="#+id/txtCommentContent"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_margin="5dp"
android:background="#drawable/bg_edittext_gradient"
android:gravity="top|start"
android:hint="#string/strHintContentComment"
android:maxLines ="4"
android:imeOptions="actionDone"
android:padding="5dp"
android:textSize="15sp"
android:textColor="#color/black"
android:scrollHorizontally="false"/>
Can anyone point out what I am doing wrong?
Did you try?
editText.setImeOptions(editText.getImeOptions()| EditorInfo.IME_ACTION_DONE);
With
android:inputType="text"
You need to add:
android:singleLine="true"
done button will show, but you can not use done button and return button(next line) same time on softkeyboard
I want to open only numeric keyboard with input type numeric password. Code is as follows.
<EditText
android:id="#+id/passcode1"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:cursorVisible="false"
android:gravity="center_vertical|center_horizontal"
android:imeOptions="actionNext"
android:inputType="numberPassword"
android:maxLength="4"
android:singleLine="true" />
Everything working great but Soft Keyboard opens with special symbols and numeric digits. I want only numeric digits must be visible there.
Thanks.
Please change android:inputType="numberPassword"
to
android:inputType="number|textPassword"
I had an issue with setting hint in Arabic language. Please refer Alternating edit text hint not visible for Arabic language
for details. The issue was with the use of inputType in the xml. I have removed it and now a normal keypad appears onclick of the edittext field. But I want the user to enter numbers only and I want numerical keypad to appear. How to do it?
In short, the use of inputType will not display the Arabic content and if it is not used then I am getting alphabetical keypad.
Please help, thanks in advance
hope you can use this property android:numeric="integer" and please remove singleline property if you are using it.
<EditText
android:id="#+id/et_account_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/transparent"
android:cursorVisible="true"
android:gravity="right"
android:hint="#string/hint_account_no"
android:imeOptions="actionNext"
android:numeric="integer"
android:maxLength="12"
android:textColor="#android:color/black"
android:textSize="20sp"
android:padding="#dimen/edittext_padding">
</EditText>
Use android:inputType="number" or android:inputType="phone" it should give you numeric keypad on click of edit text:
Following is the snippet from my xml, this should help:
<EditText
android:layout_gravity="start"
android:textAlignment="viewStart"
android:hint="my hint"
android:inputType="phone"
android:id="#+id/Nummm"
android:paddingStart="8dp"
android:paddingLeft="8dp"
android:textDirection="rtl"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:background="#android:color/transparent"
android:textColorHint="#767676"
android:backgroundTint="#android:color/transparent"
android:layout_height="fill_parent"
tools:ignore="RtlCompat" />