We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

SfAutoComplete with Numeric Keyboard on Android

Hi,

I want to replace a SearchBar with an SfAutoComplete control.

The searchbar has been customized to display the numeric keyboard (used SearchBarRenderer and set this.Control.SetInputType(InputTypes.ClassNumber); in OnElementChanged override).

I'm trying to achieve the same thing with SfAutoComplete
Instead of the standard keyboard:

The numeric keyboard (InputTypes.ClassNumber) should be displayed:


Best regards,

Thomas

3 Replies

MK Muneesh Kumar G Syncfusion Team September 25, 2019 05:43 AM UTC

Hi Thomas,

Greetings from Syncfusion.

We would like to let you know that your requirement could be achieved by using Custom Renderer. We have set the Keyboard using Renderer Class. We have prepared the same with SfAutoComplete. Please have the sample from the below link,

Sample Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/AutoCompleteNumeric-141243053

Code Snippet: 
Android: 
protected override void OnElementChanged(ElementChangedEventArgs<SfAutoComplete> e)
        {
            base.OnElementChanged(e);
            if (Control != null)
            {
                Control.GetAutoEditText().InputType = Android.Text.InputTypes.ClassNumber;
            }
        } 

iOS: 
protected override void OnElementChanged(ElementChangedEventArgs<SfAutoComplete> e)
        {
            base.OnElementChanged(e);
            if (Control != null)
            {
                Control.TextField.KeyboardType = UIKeyboardType.NumberPad;
            }
        } 

UWP: 
protected override void OnElementChanged(ElementChangedEventArgs<Syncfusion.SfAutoComplete.XForms.SfAutoComplete> e)
        {
            base.OnElementChanged(e);
            if (Control != null)
            {
                var scope = new InputScope();
                var name = new InputScopeName();
                name.NameValue = InputScopeNameValue.Number;
                scope.Names.Add(name);
                Control.InputScope = scope;
            }
        } 
  
Please check and let us know if you have any concern. 
 
Thanks, 
Muneesh Kumar G. 



NV nvrsttl September 26, 2019 11:15 AM UTC

Hi Muneesh,

thank you very much for the provided sample. It works and solves my issue.

Best regards,

Thomas


MK Muneesh Kumar G Syncfusion Team September 26, 2019 11:42 AM UTC

Hi Thomas, 
 
Thanks for the update. 
  
We are glad to know that the given solution works. Please let us know if you need any further assistance. 
  
Thanks,    
Muneesh Kumar G.    
 


Loader.
Live Chat Icon For mobile
Up arrow icon