I want to disable the paste suggestion on the soft keyboard in the EditText XML or programmatically.
The thing I'm referring to is the button with "563737" below
To disable the paste suggestion feature on the on-screen keyboard for an EditText element, you can specify the "textNoSuggestions" value for the "android:inputType" attribute in the EditText's XML definition.
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textNoSuggestions" />
Or you can set the inputType property programmatically in code:
EditText editText = findViewById(R.id.edit_text);
editText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
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 want to input EditText som characters:
android:digits="1234567890-_##."
If I don't set inputType keyboard input Text is default.
I want show number keyboard show default.
But:
If in EditText design ,i set:
android:inputType="number"
or
android:inputType="phone"
EditText don't show key (#,_)
How show default keyboard number (allow input digits="1234567890-_##.") in Edittext?
Use this :
<EditText
android:id="#+id/ed1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:inputType="number"
android:digits="1234567890-_##."/>
It works for me and allow me to insert this characters "1234567890-_##." only.
Hope this will help you.
Thanks.
I use EditText to do input actions, and set android:imeOptions="actionSend" to the widget, so that the soft keyboard can have a send button, but when I click send, the soft keyboard will disappeared, however, it's not friendly to users since user must click EditText again to use the soft keyboard, all I want is to keep the soft keyboard, does any one know how to achieve it?
Here is a piece of my layout codeļ¼
<EditText
android:id="#+id/input_area"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/emo_btn"
android:inputType="textAutoCorrect"
android:singleLine="true"
android:imeOptions="actionSend"/>
you are using setOnEditorActionListener or setOnKeyListener ? on both case try your return statement with true
I have Edit Text field where I have to input a password, but I have to push this field. How to automatically pop-up keyboard without touching the Edit Text?
There is an Edit text xml field:
<EditText
android:id="#+id/editPasswd"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:password="true"/>
Use this code in the point where you want to display the keyboard (may be in oCreate?)
EditText myEditText = (EditText) findViewById(R.id.editPasswd);
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE))
.showSoftInput(myEditText, InputMethodManager.SHOW_FORCED);
I'm assuming you mean to automatically pop it up when the activity starts. If so, adding this to the activity-tag in the manifest solved it for me (unlike Erfan's answer):
android:windowSoftInputMode="stateVisible"
One line in the Java class:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);