SoFunction
Updated on 2025-03-11

Android Setting Edittext to get focus and pop up soft keyboard

Android Setting Edittext to get focus and pop up soft keyboard

/**
    * EditText gets focus and displays soft keyboard
    */
  public static void showSoftInputFromWindow(Activity activity, EditText editText) {
    (true);
    (true);
    ();
    ().setSoftInputMode(.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
  }

ps:Android page enters edittext to automatically get focus, and the solution to pop up soft keyboard

Add the above 2 properties to the parent layout of edittext

android:focusable="true"
android:focusableInTouchMode="true"

The above is all the content of this article. I hope that the content of this article will help you study or work. I also hope to support me more!