Articles in this section
Category / Section

How to resolve missing decimal point issue on Samsung Devices (S6, S8) numeric keyboard in DataForm ?

6 mins read

When using virtual numeric keyboard in DataForm, decimal point is missing on Samsung S6 and S8 device’s numeric keyboard. This issue occurs due to Samsung devices S6 and S8 numeric KeyBoard.

 

Please find the following discussions about issue with numeric keyboard in Samsung devices:

 

https://github.com/bitpay/copay/issues/2838

https://github.com/bitpay/copay/issues/2384

https://c.getsatisfaction.com/apperyio/topics/android-numeric-keyboard-missing-decimal-point-any-workaround

 

This article explains the workaround “to show the decimal point” on virtual numeric keyboard in Samsung devices (S6, S8) by customizing the KeyListener settings in custom renderer in Xamarin.Forms Android platform.

 

Add custom editor in DataForm to customize native control renderer settings to show the decimal point in numeric keyboard.

 

Here, the Salary data field is used as custom editor.

 

 
CompanyInfo.cs
 
    public class CompanyInfo
    {
        public string Name { get; set; }
        public string Company { get; set; }
        public decimal Salary { get; set; }
    }

 

By passing custom view in DataFormEditor, you can add custom editor to data form. Refer to this data form user guide documentation to creating a new custom editor.

 

Here, the SfNumericTextBox is loaded for custom numeric textbox editor.

 

 
    public class CustomNumericTextBox: SfNumericTextBox
    {
        public CustomNumericTextBox()
        {
 
        }
    }

 

The custom view (SfNumericTextBox) property settings, custom editor value commit, data validation can be handled by overriding the required methods in the DataFormEditor class. Refer to this KB article for more details.

 

Refer to the following code example for binding the DataObject and adding custom editor as SfNumericTextBox editor using the RegisterEditor method in data form.

 

 
            dataForm.DataObject = new CompanyInfo();
 
            if (Device.RuntimePlatform == Device.Android)
            {
                dataForm.RegisterEditor("NumericTextBox", new CustomNumericTextEditor(dataForm));
                dataForm.RegisterEditor("Salary", "NumericTextBox");
            }
            else
            {
                dataForm.RegisterEditor("Salary", "Currency");
            }
 

 

In Android Renderer:

 

Return the DigitsKeyListener that accepts the digits 0 to 9 and dot (.) in native control KeyListener to show the decimal point in virtual numeric keyboard.

 

 
    [assembly: ExportRenderer(typeof(CustomNumericTextBox), typeof(CustomViewEditor))]
 
    public class CustomViewEditor : SfNumericTextBoxRenderer
    {
        public CustomViewEditor()
        {
 
        }
        protected override void OnElementChanged(ElementChangedEventArgs<SfNumericTextBox> e)
        {
            base.OnElementChanged(e);
            if (Control != null)
            {
                Control.InputType = Android.Text.InputTypes.TextFlagCapWords;
                Control.KeyListener = Android.Text.Method.DigitsKeyListener.GetInstance("0123456789.");
            }
        }
    }
 

 

Example: NumericKeyBoardDecimalPoint

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied