Samsung Devices opens Wrong Keybaord - android

Below code opens numeric Keyboard on some Samsung Devices , Devices include Samsung s7 Edge,A9.
<EditText
android:id="#+id/prdtName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/Product"
android:text="#={product.productName}"
android:singleLine="true"
android:background="#drawable/edittext"
android:padding="15dp"
android:layout_margin="10dp"
bind:font="#{AppConstants.OpenSansRegular}"
android:inputType="textCapWords"
/>

can you please add the android verion of the devices you tested on?
As I understand, you want to open keyboard and allow the user to enter just capital letters. There is multiple ways to do it :
android:inputType="textCapSentences" will work for sentences to request capitalization of the first character of every sentence.
android:inputType="textCapCharacters" to request capitalization of all characters.
android:inputType="textCapWords"to request capitalization of the first character of every word.
These can be combined with text and its variations like textPersonName , textPostalAddress, textShortMessage and more...
for example : android:inputType="textCapWords|textCapSentences" and android:inputType="textPostalAddress|textCapSentences"
check the documentation : https://developer.android.com/reference/android/widget/TextView.html#attr_android:inputType
Or you might do it programatically :
EditText input = (EditText).findViewById(R.id.ID);
input.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
You can also use android:capitalize, it works on some cases and should automatically capitalize what the user types.
android:inputType="none", which won't automatically capitalize anything.
android:inputType="sentences", Which will capitalize the first word of each sentence.
android:inputType="words", Which Will Capitalize The First Letter Of Every Word.
android:inputType="characters", WHICH WILL CAPITALIZE EVERY CHARACTER.
If all these suggestions doesn't work for you, it's a problem with samsung devices and with some specific android versions. Try to fix that from keyboard settings like suggested here: https://stackoverflow.com/a/31699306/12802591

Related

Android EditText - Input with numbers only

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.

EditText inputType for numbers in a tablet device, always showing extra keys

I am setting an EditText for a tablet device that takes only numbers, but an extra keypad with mathematical operators and extra options appear to the left of the numbers:
My EditText is defined like this:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/text_container"
android:id="#+id/edit_text"
android:hint="123-4567890"
android:digits="0123456789"
android:inputType="number"
android:layout_centerHorizontal="true"
android:textSize="36sp"
android:gravity="center_horizontal"
android:maxLength="10"
android:imeOptions="actionDone"
>
</EditText>
If I set the inputType to "numberPassword" I get my desired result:
Running the app in a phone device, with the inputType set to "number", also displays what I want:
Why is it showing the extra keyboard part in a tablet device?
How can I get the EditText to display only numbers in the tablet, just as it does using a phone device or just as it does with the "numberPassword" inputType option?
Cheers!
Why is it showing the extra keyboard part in a tablet device?
Because it that's how it is designed.
How can I get the EditText to display only numbers in the tablet,
You can't. If you need particular layout of keys, you'd need to implement this yourself.
Still, why would you even bother? User can have any keyboard he wants, even physical one so you should always filter what is being entered anyway. See https://developer.android.com/reference/android/text/InputFilter

Android Edittext Using inputtype as Phone cannot use letter only numbers

In my Android application, I have a field where 95% off the time it's only numbers.
So I set the inputtype of my edittext as "number"
But I have some case where the user must enter char in the field Ex : AF1233636
In my case using the standard alpha numeric keyboard is a bad option because users must wear gloves.
So I found the inputype "phone" where there is number and chars but only numbers are working.
I cannot get char inside my fields only numbers
<EditText
android:id="#+id/fld_tag"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:clickable="true"
android:cursorVisible="false"
android:inputType="phone"
android:digits="0123456789abcdefghijklmnopqrstuvwxyz"
android:focusable="true"
android:maxLength="10"
android:textStyle="bold" />
So when the user stay push on a number I want the char appear as it was working on old phone to write text.
Any idea ?
Check out this tutorial for creating a custom IME https://code.tutsplus.com/tutorials/create-a-custom-keyboard-on-android--cms-22615 ... create something similar to this except with t9 functionality. Those letters underneath the numbers are just for visualizing when typing in a phone style app.

Android - Bug with EditText with digits parameter

I am currently experiencing a strange bug with EditText with the android:digits parameter.
Here is the XML of the EditText :
<EditText
android:id="#+id/edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:hint="#string/some_text"
android:imeOptions="actionDone"
android:singleLine="true"
android:digits="abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ\\ "
android:maxLength="140"
android:textSize="#dimen/font_size_small"/>
As you can see, this EditText allows the user to type only alpha-numerics characters.
Now, if I try to use this EditText, the EditText is correctly filtering the chars i'm typing
but ... if I type some chars then directly followed by %, the previously typed chars are copied in the EditText !
Eg: I'm typing on my keyboard hello%%, the result in the EditText will be hellohellohello.
Has any of you already experienced such a bug ? Is it from the Android platform ? Should I report it or has it already been ?
For information, my device is a Nexus 4 with Android 4.3.
Thank you !
The problem is with the Android Keyboard (AOSP). I was trying it using SwiftKey and couldn't recreate it. I changed to the default keyboard and the problem occurs.
The problem occurs because Android Keyboard is trying to learn/suggest words you're typing in. I'm not sure if the bug has been reported, but you can avoid this problem by using android:inputType="textNoSuggestions"

Why input type "number" is showing alphabet keyboard for an edit text...?

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.

Categories

Resources