Android realizes EditView gets focus but does not pop up soft keyboard

When I solved this problem, I searched a lot of solutions on the Internet, but they couldn’t solve the problem. The
soft keyboard will still pop up. Now I’m sharing this bear’s solution.

  1. Find the activity that does not want to pop up the soft keyboard in the AndroidManifest.xml file
  2. Add android:windowSoftInputMode="stateHidden|stateAlwaysHidden" to the activity tag, pay attention to the location, add it in the tag <activity android:name=".MainActivity" android:label="@string/app_name" android:theme="@style/AppTheme.NoActionBar" android:windowSoftInputMode="stateHidden|stateAlwaysHidden">
  3. Insert in the corresponding Java file
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    
                           //阻止键盘弹出
            text.setShowSoftInputOnFocus(false);
        }

replace text with your EditView variable name

This method is suitable for Android 5.0 and above (why did not write anything below 5.0, after all, few people use it (●'◡'●)))

Guess you like

Origin blog.csdn.net/qq_42790573/article/details/113031455