我有一个编辑文本。它包含属性数字和imeOptions (actionDone)。
<android.support.v7.widget.AppCompatEditText
android:id="@+id/edit_text_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="1234567890abcdefghijklmnopqrstuvwxyz....."
android:hint="@string/item_name"
android:imeOptions="actionDone"
android:maxLines="1" />同时使用digit && imeOptions属性时,找不到actionDone (Softkeyword中的完成按钮)。我们只能找到enter按钮,它不会改变焦点。我尝试跳过数字属性,然后imeOptions就可以正常工作了。提前感谢
发布于 2017-02-27 16:25:10
只需将singleLine="true“添加到您的编辑文本中
android:singleLine = "true"发布于 2017-12-14 01:07:26
在EditText视图上使用setRawInputType()
view.setRawInputType(view.getInputType() & ~EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE)调用setRawInputType()而不是setInputType()很重要,因为后者将基于inputmethod设置密钥侦听器,并且您的android:digits属性将被丢弃。setRawInputType()只会改变inputmethod,它不会接触到KeyListener,而且& ~EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE会禁用多行模式,所以不会显示任何return键,相反,您选择的imeOption应该是可见的。
基本上,singleLine和maxLines的行为是不同的。
发布于 2017-08-31 09:03:05
我对"android:digits“的测试似乎在编辑文本字段中导致了问题,并且当将imeOptions设置为android:imeOptions="actionDone”时,我无法在键盘上显示“完成”按钮。
有一次我用
android:inputType="text"在没有数字设置的情况下,键盘会显示“完成”(或者根据你的设备的键盘打个勾),然后我可以使用以下命令来捕获击键:
editextField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
int result = actionId & EditorInfo.IME_MASK_ACTION;
switch(result) {
case EditorInfo.IME_ACTION_DONE:
// put your code here.
break;
}
return false;
}
}); https://stackoverflow.com/questions/42480576
复制相似问题