Android N (7.0) when the soft keyboard pops up when the edittext is displayed in the ListView, will it automatically switch to the full keyboard? Problem symptom Description
- Activity is set in Androidmanifest.xml.
android:windowSoftInputMode="adjustPan"
- Draw Item in ListView
- The item control is EditText
- EditText setting InputType to Number
- When you click EditText on the Android 7.0 system, the soft keyboard that pops up is "digital" input mode, but instantly switches to "full keyboard" mode.
No such problem occurred in the system before 7.0.
A tentative solution (risk not evaluated)
/** * Tried to fix the problem that the pop-up soft keyboard automatically switches from the numeric keypad to the English full keyboard when displaying EditText InputType as other non-text types in the ListView. */class ListViewEx2 extends Listview{public ListViewEx2 (final context context) {super (context);} Public ListViewEx2 (Final context context, final AttributeSet attrs) {Super (context, attrs);} Public ListViewEx2 (Final context context, final AttributeSet attrs, final int defstyleattr) {Super (context, Attrs, DefS TYLEATTR);} @TargetApi (build.version_codes. LOLLIPOP) Public ListViewEx2 (final context context, final AttributeSet attrs, final int defstyleattr, final int defstyleres ) {Super (context, Attrs, defstyleattr, defstyleres);} @Overrideprotected void OnLayout (Final boolean changed, Final int l, final int T, final int R, final int b) {//xxx: After preliminary Test, only the Android 7.0 platform above the system will appear on the soft keyboard automatic switching problem. if (Build.VERSION.SDK_INT >= build.version_codes. N && changed) super.onlayout (changed, L, T, R, b); else Super.onlayout (changed, L, T, R, b);}}
Listview.java Source Comparison
Android version Name: Nougat API level:24 Listview.java Online View
Android 7 part of suspicious changed source code
Private class Focusselector implements Runnable {//The selector is waiting to set selection on the list VI EW private static final int state_set_selection = 1; The selector set the selection on the list view, waiting for a Layoutchildren pass private static final int State_wa It_for_layout = 2; The selector ' s selection has been honored and it's waiting to request focus on the/target child. private static final int state_request_focus = 3; public void Run () {if (maction = = state_set_selection) {setselectionfromtop (mposition, mpositiontop); Maction = State_wait_for_layout; } else if (maction = = State_request_focus) {final int childindex = mposition-mfirstposition; Final View child = Getchildat (Childindex); if (child! = null) {Child.requestfocus (); } maction =-1; } } }}
Android version name: Marshmallow API level:23 Listview.java Online View
Android 6 part of suspicious changes to the old version of the source code
private class FocusSelector implements Runnable { public void run() { setSelectionFromTop(mPosition, mPositionTop); } }
Resources
- Keyboard-issue with Edittext InputType & Focus Android N (7.0)-Stack Overflow
Android N (7.0) in the ListView display EditText when the soft keyboard pops up automatically switch to the full keyboard problem?