Exemple #1
0
        private bool HideKeyboardAttemptTwo()
        {
            if (inputMethodManager == null || !(mainActivity is Activity activity))
            {
                return(false);
            }

            Logging.Log(LogType.Information, $"Attempting to Hide Keyboard via 2nd method...");

            //var view = activity.CurrentFocus;
            var view = activity.FindViewById(Android.Resource.Id.Content).RootView;

            if (view == null)
            {
                Logging.Log(LogType.Warning, $"Failed to get View from Activity...");
            }

            var token = view?.WindowToken;

            if (token == null)
            {
                Logging.Log(LogType.Warning, $"Failed to get Token from View...");
            }

            inputMethodManager.ToggleSoftInputFromWindow(token, ShowSoftInputFlags.None, HideSoftInputFlags.None);

            if (!IsKeyboardShown)
            {
                view?.ClearFocus();
                return(true);
            }

            Logging.Log(LogType.Warning, $"Failed to Hide Keyboard via {nameof(inputMethodManager.ToggleSoftInputFromWindow)}...");
            return(false);
        }
Exemple #2
0
        public void ToggleKeyboard(Action <Single> onLayoutChanged)
        {
            _onLayoutChanged = onLayoutChanged;

            InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);

            imm.ToggleSoftInputFromWindow(_view.WindowToken, ShowSoftInputFlags.Forced, HideSoftInputFlags.ImplicitOnly);
        }
Exemple #3
0
 public void Activate(object sender)
 {
     activity.RunOnUiThread(() =>
     {
         view.RequestFocus();
         inputMethodManager.ToggleSoftInputFromWindow(view.WindowToken, ShowSoftInputFlags.Forced, HideSoftInputFlags.None);
         view.KeyDown    += keyDown;
         view.CommitText += commitText;
     });
 }