I am trying to make an EditText such that, when I click it, a keyboard containing ".com" appears, because a URL is to be entered into the EditText.
I tried to use this:
android:inputType="textUri"
but it is not working. How do I do it?
try this one
<EditText
android:id="#+id/edt"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:inputType="textWebEmailAddress"
/>
android:inputType="textWebEmailAddress"
use this property for that.
You can use inputType as textWebEmailAddress or textEmailAddress. Specs say it is device dependent but honestly I did not find any difference. Purpose of using this is you can use the # and .com keys in the keypad. I tried both on samsung Galaxy S5 and keypad is the same.
Related
I created an EditText that only allows numbers as an input. It's a very simple EditText with nothing special:
<EditText
android:id="#+id/editTextAmount"
android:layout_marginTop="10dp"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
android:inputType="text"
android:digits="0123456789"
/>
I tried it on a few devices and it's working as expected, I can enter only numbers. The issue arise when using a Samsung Galaxy Note S10+ (with a Samsung keyboard, I think the issue comes from there). With that device when I focus the EditText the keyboard opens (with only number visible) but when I type something in the field nothing happens. I can press any key from the keyboard (enter key, numbers, ...) nothing changes.
I tried to change the input type programmatically in the activity, I tried to fiddle with the inputType (numberDecimal, numberSigned, both, ...) in any case it is simply not working. The interesting thing is that if I change the inputType to "text" and remove the digits restriction then it is working perfectly.
My question is: How can I limit the EditText input to numbers with a Samsung Galaxy Note S10+?
EDIT: Just to make it perfectly clear, I am asking this for a specific device! I already tried:
android:inputType="number"
And
editText.setInputType(InputType.TYPE_CLASS_NUMBER);
And
any variation of those (numberDecimal, numberSigned, ...)
in Java class set input type like this
editText.setInputType(InputType.TYPE_CLASS_NUMBER);
or if you want to do that from layout then set
android:inputType="number"
It seems to work well with this configuration:
android:digits="0123456789"
android:inputType="phone"
That's a good enough workaround for me.
How to disable auto suggestion with input type : textEmailAddress, while using like below the auto suggestion will appear, exactly want stop auto suggestion with email keyboard.
Used Code
<EditText
android:hint="Logesh"
android:inputType="textEmailAddress|textNoSuggestions|textMultiLine "
android:layout_width="match_parent"
android:importantForAutofill="no"
android:layout_height="match_parent" />
and i tried below also
<EditText
android:hint="Logesh"
android:inputType="textEmailAddress|textVisiablePassword"
android:layout_width="match_parent"
android:importantForAutofill="no"
android:layout_height="match_parent" />
when using textVisiblePassword that input of keyboard "#" not shown.
Thanks in advance !
Add this one in your EditText -
android:inputType="textFilter|textEmailAddress|textNoSuggestions"
and remove android:importantForAutofill="no"
Can you try by adding textFilter property in your android:inputType?
android:inputType="textFilter|textEmailAddress|textVisiablePassword"
android:inputType="textNoSuggestions"
Android has great documentation, check the InputType section of TextViews here
android:importantForAutofill="no"
android:inputType="textEmailAddress"
These two lines worked for me.
I’m not sure it’s exactly what you were looking for, but I needed a way to keep the keyboard layout with the # and shortcuts, but avoid saving the email in the keyboard suggestions for privacy purposes, as it’s for a kiosk app.
In the end I managed it by using:
android:importantForAutofill="no"
android:inputType="textWebEmailAddress"
I want the soft keyboard in my app to show Done when clicking on a particular EditText. This is how it looks
<EditText
android:id="#+id/code_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/enter_code_textView"
android:layout_marginStart="#dimen/margin_25dp"
android:layout_marginLeft="#dimen/margin_25dp"
android:layout_marginTop="#dimen/margin_12dp"
android:layout_marginEnd="#dimen/margin_25dp"
android:layout_marginRight="#dimen/margin_25dp"
android:background="#drawable/edittext_background"
android:maxLines="1"
android:inputType="text"
android:imeOptions="actionDone"
android:textColor="#color/black"
android:textCursorDrawable="#null"
android:textSize="16sp" />
But this doesn't work. The soft keyboard enter key text doesn't change at all. I tried this on multiple devices, one Oreo and one KitKat. I also tried using singleLine attribute but that doesn't work too. What am I missing here? Thanks in advance!
There's no way to force the soft keyboard to show any key, not even the imeOptions. The keyboard app uses that as a hint- it doesn't have to honor it. And remember that every different keyboard will make different choices on whether or not to honor it. And that there is no such thing as the "default keyboard" as many OEMs replace it. Basically, you can set the imeOptions and hope it works, but there's no way to force it to work across all devices and keyboard apps.
I am using MaterialEditText library.
Though I tried removing the MaterialEditText library and using normal EditText also doesn't work.
The issue is When I try to put inputType="textPassword" or inputType="number" or inputType="numberDecimal" my editText doesnt take number as input.
I tried with multiple phones. What I got to know it works correctly in SAMSUNG phones and not in other phones.
AM I missing something?
<com.rengwuxian.materialedittext.MaterialEditText
android:id="#+id/mobile_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/activity_horizontal_margin"
android:layout_marginStart="#dimen/activity_horizontal_margin"
android:hint="#string/mobile_number"
android:inputType="numberDecimal"
android:textSize="#dimen/font_size_sub_normal"
app:met_clearButton="true"
app:met_floatingLabel="normal"
app:met_floatingLabelTextColor="#color/colorPrimary" />
even if I use normal editText it doesn't work.
If I remove InputType than it works.
EDIT :
I just found that issue is with Google Keyboard. Everything works fine with samsung keyboard but inputType with Google Keyboard not working. Not working in the sense it is not taking numbers
Try to use solution provided by google (support library)
EditText with TextInputlayout
I have a edit text, whose input type is number.
in emulator its working fine i.e, showing the num-pad as soft keypad.
but in the device its showing alphabets keyboard why?
<EditText android:layout_width="110dp"
android:layout_height="30dp" android:id="#+id/phone"
android:layout_alignParentRight="true" android:background="#drawable/edit_text_bg"
android:inputType="number" android:maxLength="10"
android:paddingLeft="4dp" android:textColor="#1b0a00"
android:layout_marginRight="8dp"/>
Thanks in advance....!
So from what i've observed setting the inputType to phone should solve the problem . But try a different device to check if ur code works by giving input as number before moving to this option .
I think you must change inputType
FROM :
android:inputType="number"
TO:
android:inputType="phone"
When you give the InputType as number there is a completely new keyboard that gets loaded very different to what you will get by pressing the corner button on your normal keyboard to get numbers . Only certain phones/android versions(i think 2.2+) have this separate keyboard . For the ones that dont have this , The normal keyboard is shown and manual switching has to be done .
It could be that the device you're testing has some sort of custom keyboard enabled by default that doesn't support a number pad. Try changing the keyboard settings to the standard keyboard on the device and see if it works.