Maui android screen keyboard for entry when keyboard is showing
Hello all. I use entry handler to prevent keyboard pop when the entry has focused and it works ok but if the keyboard is already showing and I tap the entry field the keyboard still showing and I need to manually hide it. How I can fix that programmatically. Thank you very much.
Developer technologies | .NET | .NET MAUI
-
Anonymous
2023-10-04T04:07:27.57+00:00 I tried to use hideSoftInputFromInputMethod to hide softkeyboard programmatically when specific entry get focus, but this method is deprecated, if I use InputMethodService#requestHideSelf(int) instead. This method was intended for IME developers, do you want to create custom keyboard completely for android platform?
-
Haviv Elbsz • 2,071 Reputation points
2023-10-04T05:09:14.94+00:00 Lu Thank you very much. Actually I tried to completely customize the keyboard but I don't know how to. I have already done one for one entry field with a grid hide show technic . If you can direct me to do a popup keyboard I'll appreciate your efforts and that will make me happy. Thank you.
-
Anonymous
2023-10-05T06:07:43.9433333+00:00 Here is a native android document about InputMethodService, you can refer to it.
-
Haviv Elbsz • 2,071 Reputation points
2023-10-05T08:33:08.1133333+00:00 Hi Lu and thank you very much. But I found its hard for me without an example so I think I'll wait with my user input improvement until I find something that I can perform. again thank you very much.
-
Haviv Elbsz • 2,071 Reputation points
2023-10-05T09:08:03.84+00:00 Hi again I noticed that when keyboard shown the back button triangle icon show downward instead of leftward and when I tap it the keyboard disparu can I simulate this programmatically.
-
Anonymous
2023-10-06T06:47:53.66+00:00 Could you share a screenshot about this issue? I will try to implement inputmethodService in MAUI.
-
Haviv Elbsz • 2,071 Reputation points
2023-10-10T19:50:27.5833333+00:00 when manually tap the back button the keyboard is hidden
-
Haviv Elbsz • 2,071 Reputation points
2023-10-10T19:54:06.3433333+00:00 when manually tap the back button the keyboard is hidden
-
Haviv Elbsz • 2,071 Reputation points
2023-10-11T06:58:38.62+00:00 Hi Lu and thank you very much. sorry about the lateness. As you can see in the screenshot before I tap to show my small entry keyboard the system popup keyboard is shown and I can manually hide it by tapping the back button what I want to do is done it programmatically. of course ideally change the popup keyboard according the entry needs is preferably. Thank you again.
-
Anonymous
2023-10-12T05:11:40.8466667+00:00 Based on your screenshot, you create a custom keyboard, but android provide the same keyboard after your set
<Entry Keyboard="Numeric">
, you do not need to create a new custom keyboard and hide the system keyboard. -
Haviv Elbsz • 2,071 Reputation points
2023-10-12T05:41:41.11+00:00 I checked all the options provided by the options email, numeric,... no one has the characters I need. the characters I need are all digits and ! a b * = < > - and a space char. Thank you.
-
Anonymous
2023-10-13T10:02:35.5666667+00:00 You can Migrate a custom renderer to a .NET MAUI handler to create a custom entry, then return following custom edittext to hide keyboard when
OnCheckIsTextEditor
andOnSelectionChanged
event executedpublic sealed partial class CustomEditorHandler : ViewHandler<CustomEntryNoKeyboard, EditText> { protected override EditText CreatePlatformView() { return new NoKeyEditText(Context); } protected override void ConnectHandler(EditText platformView) { base.ConnectHandler(platformView); } static void MapIsKeyboardEnabled(CustomEditorHandler handler, CustomEntryNoKeyboard editor) { } } #if ANDROID public class NoKeyEditText : EditText { Context context; public NoKeyEditText(Context context) : base(context) { this.context = context; } protected NoKeyEditText(nint javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) { } public override bool OnCheckIsTextEditor() { HideKeyBoard(); return base.OnCheckIsTextEditor(); } private void HideKeyBoard() { InputMethodManager inputMethodManager = Microsoft.Maui.ApplicationModel.Platform.CurrentActivity.GetSystemService(Context.InputMethodService) as InputMethodManager; // context.GetWindow() inputMethodManager.HideSoftInputFromWindow(this.WindowToken, HideSoftInputFlags.None); } protected override void OnSelectionChanged(int selStart, int selEnd) { HideKeyBoard(); base.OnSelectionChanged(selStart, selEnd); } } #endif }
-
Haviv Elbsz • 2,071 Reputation points
2023-10-13T14:45:03.61+00:00 This learn.microsoft.com page can’t be found
No webpage was found for the web address: https://learn.microsoft.com/en-us/dotnet/maui/migration/renderer-to-handler"https://learn.microsoft.com/en-us/dotnet/maui/migration/renderer-to-handler"
HTTP ERROR 404
-
Anonymous
2023-10-16T02:38:43.19+00:00 I update it, can you access this link? Or open this link https://learn.microsoft.com/en-us/dotnet/maui/migration/renderer-to-handler
-
Haviv Elbsz • 2,071 Reputation points
2023-10-16T07:13:16.77+00:00 Hi Lu and thank you very much. waw so many to learn and so many to codes and so little to action. I accept this as answer but I'll prefer waiting to maui to do it for me. Again thank you very much.
-
Anonymous
2023-10-16T07:34:54.39+00:00 You are welcome. Yes, achieving this is more complicated. Because I tried to use EntryHandler and following code to hide it when Entry click event is executed. But it is not working at the first time click event. And it is working at next time click event, so we have to re-write Edittext for android platform. We need to hide the softkeyboard during initialization
InputMethodManager inputMethodManager = Microsoft.Maui.ApplicationModel.Platform.CurrentActivity.GetSystemService(Context.InputMethodService) as InputMethodManager; // context.GetWindow() inputMethodManager.HideSoftInputFromWindow(this.WindowToken, HideSoftInputFlags.None);
-
Haviv Elbsz • 2,071 Reputation points
2023-10-16T09:16:06.55+00:00 Lu I'm thank you.
-
Anonymous
2023-10-16T09:31:03.43+00:00 It's my pleasure. Happy coding.
-
Haviv Elbsz • 2,071 Reputation points
2023-10-16T09:40:59.3733333+00:00 Lu I feel compelled to say something. in a long time you helped me with answers that helped me to bring my application as shown in the above screenshot.
Sign in to comment