Close Keyboard on android

4 posts, 0 answers
  1. Pierre
    Pierre avatar
    257 posts
    Member since:
    Apr 2007

    Posted 18 Mar Link to this post

    Hi, how I can hide the overlay keyboard from appearing after set the focus oin the NumericInput.

    For now I try with Depedency on cross platform without success

    RadNumericInput ntb = Qte as RadNumericInput;
    if (ntb != null)
    {
        ntb.Focus();
        var key = Xamarin.Forms.DependencyService.Get<IForceKeyboardDismissalService>();
        key.DismissKeyboard();
    }

     

    then on droid:

    [assembly: Xamarin.Forms.Dependency(typeof(AndroidForceKeyboardDismissalService))]
    namespace KelvinMobile.Droid
    {
        public class AndroidForceKeyboardDismissalService : IForceKeyboardDismissalService
        {
            public void DismissKeyboard()
            {
                InputMethodManager imm = InputMethodManager.FromContext(CrossCurrentActivity.Current.Activity.ApplicationContext);
     
                imm.HideSoftInputFromWindow(CrossCurrentActivity.Current.Activity.Window.DecorView.WindowToken, HideSoftInputFlags.NotAlways);
            }
        }
    }

     

    The call work, but the keyboard still there...

     

  2. Yana
    Admin
    Yana avatar
    4865 posts

    Posted 22 Mar Link to this post

    Hi Pierre,

    You would need to get the RadEntry used inside the NumericInput control and create a custom renderer on Android for it where you could hide the keyboard.

    I've created a sample project to show you how exactly this would work.  First, in order to get the entry, you would need to modify the ControlTemplate of the NumericInput. 
    Inside the ControlTemplate replaced the NumericInputEntry with a custom one which type is used to export a renderer on Android.

    Inside the renderer you could handle GotFocus event and hide the keyboard in it.  In addition, our Entry has some specifics related to styling its border, that's why creating a new natice control is needed.

    Please download the attached file and give it a try. Let me know if any additional questions arise.

    Regards,
    Yana
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Pierre
    Pierre avatar
    257 posts
    Member since:
    Apr 2007

    Posted 25 Mar in reply to Yana Link to this post

    Great! Your sample work great and I convert it into my solution. Thanks a lot. Can you prodie me the custum renderer and/or MyNativeControl.cs for IOS and UWP? We plan to expend this program to IOS and windows soon. Thanks
  4. Yana
    Admin
    Yana avatar
    4865 posts

    Posted 28 Mar Link to this post

    Hi Pierre,

    I am afraid I couldn't find a straightforward way to implement this on iOS (the internal implementation is different on each platform) , so I have logged a feature request on your behalf, you could cast your vote and track its status at the link below:
    https://feedback.telerik.com/xamarin/1402574-entry-provide-a-way-to-override-the-behavior-of-the-keyboard

    As to UWP - generally, I do not think such a feature would be applicable, still, we will have it in mind as well.

    Let me know if I can help with anything else.

    Regards,
    Yana
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top