This is a migrated thread and some comments may be shown as answers.

Close Keyboard on android

3 Answers 413 Views
NumericInput
This is a migrated thread and some comments may be shown as answers.
Pierre
Top achievements
Rank 1
Iron
Pierre asked on 18 Mar 2019, 08:31 PM

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...

 

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 22 Mar 2019, 10:16 AM
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
0
Pierre
Top achievements
Rank 1
Iron
answered on 25 Mar 2019, 03:44 PM
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
0
Yana
Telerik team
answered on 28 Mar 2019, 10:46 AM
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
Tags
NumericInput
Asked by
Pierre
Top achievements
Rank 1
Iron
Answers by
Yana
Telerik team
Pierre
Top achievements
Rank 1
Iron
Share this question
or