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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SfAutoComplete with Numeric Keyboard on Android

Thread ID:

Created:

Updated:

Platform:

Replies:

147800 Sep 24,2019 02:32 PM UTC Sep 26,2019 11:42 AM UTC Xamarin.Forms 3
loading
Tags: SfAutoComplete
nvrsttl
Asked On September 24, 2019 02:32 PM UTC

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

Muneesh Kumar G [Syncfusion]
Replied On 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. 


nvrsttl
Replied On 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

Muneesh Kumar G [Syncfusion]
Replied On 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.    
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon