我遇到了一个奇怪的问题,点击 ListView
中的 EditText
打开数字键盘,然后闪烁文本键盘,然后返回到数字键盘。即使在其他 EditText
之间切换,此后也不会再次发生。如何防止显示文本键盘?
这是相关的调试控制台输出:
W/IInputConnectionWrapper: beginBatchEdit on inactive InputConnection
W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper: getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper: getSelectedText on inactive InputConnection
W/IInputConnectionWrapper: endBatchEdit on inactive InputConnection
W/IInputConnectionWrapper: beginBatchEdit on inactive InputConnection
W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper: getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper: getSelectedText on inactive InputConnection
W/IInputConnectionWrapper: endBatchEdit on inactive InputConnection
这是我在activity_main
中的EditText
:
<EditText
android:id="@+id/editText_lot1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText_lot2"
android:layout_alignBottom="@+id/editText_lot2"
android:layout_marginLeft="145dp"
android:layout_marginStart="145dp"
android:layout_alignParentLeft="true"
android:inputType="number"
android:ems="7"
android:textSize="14sp" />
我尝试过的:
如果我删除 android:inputType
,那么一切都会正常工作,除了现在出现拼写检查错误,并且键盘显然是文本键盘。
我尝试在 onCreate()
的 MainActivity
中添加一些内容,例如
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
我在这里搜索了问题,发现one similar case with no answers.有什么解决办法吗?
最佳答案
通过将以下内容放入我的 AndroidManifest.xml
中找到了解决方案:
android:windowSoftInputMode="adjustPan"
在我对应的<activity>
下堵塞。从 here 找到解决方案在评论中。
关于java - 数字 EditText 暂时显示文本键盘(输入连接无效),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49287228/