Xamarin.forms: Samsung Device, Numeric Keyboard -> No comma, dot event not fired

Created on 16 Feb 2018  路  13Comments  路  Source: xamarin/Xamarin.Forms

Description

When i create an entry with keyboardtype numeric and run my app on samsung devices, the keyboard shows not a comma key (,). It only shows a dot key (.). But when i press the dot key, the TextChanged event is not fired.

We confirmed this behavior on a Samsung Galaxy Tab A (2016) and Samsung A5. When we install an other keyboard than the standard samsung keyboard (like SwiftKey) it works but this would be not an user-friendly solution. Numeric keyboard works correctly on devices from HTC, Sony, LG etc.

Steps to Reproduce

Xamarin.Forms.Entry entry = new Xamarin.Forms.Entry();
entry.Keyboard = Xamarin.Forms.Keyboard.Numeric;

Run this on an actual samsung device.

Expected Behavior

It would be optimal if the comma key is displayed and working. Alternatively, but should at least the dot key fire the TextChanged Event.

Actual Behavior

The keyboard shows not a comma key (,). It only shows a dot key (.). But when i press the dot key, the TextChanged ist not fired.

Basic Information

  • Version with issue: 2.5.0.91635
  • Last known good version: I do not know exactly but any version of august or september 2017
  • IDE: Visual Studio 2017
  • Platform Target Frameworks:

    • iOS: 9.0

    • Android: 8.0

  • Affected Devices: All actual Samsung devices

Screenshots

https://ibb.co/hiTnFn

Most helpful comment

I think I found a solution for the comma issue on Samsung devices. I am using a custom Entry implementation in platform independent XAML content page. In the Android project I am then using a custom entry renderer that overrides the OnElementChanged method. My sample code snippet looks like this:

`protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);

        if (Control != null)
        {
            this.Control.KeyListener = DigitsKeyListener.GetInstance(true, true); // I know this is deprecated, but haven't had time to test the code without this line, I assume it will work without
            this.Control.InputType = Android.Text.InputTypes.ClassNumber | Android.Text.InputTypes.NumberFlagDecimal;
        }
    }`

That does the trick for me and now I can enter commas also on Samsung devices.

All 13 comments

What language do you have set as your testing locale?

German

Upon review this is an issue with the custom Samsung keyboards themselves. They do not respect the current locale and thus result in the wrong keys being displayed. I don't think there is any way for us to fix this however I would be excited to hear if there is one.

The best advice I can give is don't use a numeric keyboard on samsung phones on locales that use a , separator :/

I think I found a solution for the comma issue on Samsung devices. I am using a custom Entry implementation in platform independent XAML content page. In the Android project I am then using a custom entry renderer that overrides the OnElementChanged method. My sample code snippet looks like this:

`protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);

        if (Control != null)
        {
            this.Control.KeyListener = DigitsKeyListener.GetInstance(true, true); // I know this is deprecated, but haven't had time to test the code without this line, I assume it will work without
            this.Control.InputType = Android.Text.InputTypes.ClassNumber | Android.Text.InputTypes.NumberFlagDecimal;
        }
    }`

That does the trick for me and now I can enter commas also on Samsung devices.

Great work around, saved my day!

@harrykimpel thanks for the help, it works for me.

Great! The workaround works like charm

Please, anybody could please post the complete solution to Workaround this?

You have asked on xamarin forums and there is reply there. It didnt help?

The reply here is a bit different of others I tested and that didn't work. I just implemented it, but I don't have a Samsung Device to test it. My client will test it tomorrow and then give a feedback if it worked or not.

As i wrote on forum, reply here is outdated. Please follow forum reply and if you have any further question you can ask there

As i wrote on forum, reply here is outdated. Please follow forum reply and if you have any further question you can ask there

Can you post the link to the forum

This solution works.

Was this page helpful?
0 / 5 - 0 ratings