Maui 17.9 preview 5 android 34 is now there's a keyboard custom

Haviv Elbsz 2,091 Reputation points
2024-02-06T09:58:51.7133333+00:00

Hello all. is now in 17.9 preview 5 and android 34 there is a fully customized keyboard. mainly a keyboard with a special keys that fit my application need. Thank in advanced.

Developer technologies | .NET | .NET MAUI
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2024-02-08T04:01:11.11+00:00

    Hello,

    I wonder why android not allow to change characters according the developer need.

    Actually, Android itself supports a fully customized keyboard, but you need to design the keyboard page completely yourself and connect it to Android through the InputMethodService.

    However, this process is currently not available in MAUI, because the custom page cannot be called in the Resource class after the layout is created.

    public class MyIMService : InputMethodService, View.IOnClickListener
    {
    
        private static String TAG = "MyIMService";
        public override global::Android.Views.View? OnCreateInputView()
        {
            var myKeyboardView = LayoutInflater.Inflate(Resource.Layout.MyKeyboard, null); // Here you will get an error that the reference could not be found
            Button btnA = myKeyboardView.FindViewById(Resource.Id.search_button) as Button;
            btnA.SetOnClickListener(this);
            //ADD ALL THE OTHER LISTENERS HERE FOR ALL THE KEYS
            return myKeyboardView;
        }
        public void OnClick(View? v)
        {
            var ic = CurrentInputConnection;
            if (v is Button) {
                String clickedKeyText = ((Button)v).Text.ToString();
                ic.CommitText(clickedKeyText, 1);
            }
        }
    }
    

    Therefore, in the current MAUI, an alternative solution is through a pop-up window with Entry, the layout under the Entry that you could set up as a keyboard-style grid view, and add content to the Entry via a click event.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.