我已经尝试过在这里建议的非常受欢迎的答案
尽管这对我没有用,但其他用户似乎也没有用。也许它已经过时,或者我的代码有冲突。
这是我的xml EditText
:
<EditText
android:id="@+id/editText_letter_entry"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="@drawable/edit_text_rounded"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"
android:drawableEnd="@drawable/ic_search_black_24dp"
android:hint="@string/enter_letters"
android:importantForAutofill="no"
android:inputType="text|textNoSuggestions|textVisiblePassword"
android:maxLength="15"
android:maxLines="1"
android:imeOptions="actionSearch"
android:paddingLeft="@dimen/et_padding_left_right"
android:paddingRight="@dimen/et_padding_left_right"
app:layout_constraintBottom_toTopOf="@+id/bottomBannerAdView"
app:layout_constraintEnd_toStartOf="@+id/guideline2Container"
app:layout_constraintStart_toStartOf="@+id/guideline1Container"
app:layout_constraintTop_toTopOf="parent" />
正如你可以看到我有android:imeOptions="search" & android:inputType="text"
沿textNoSuggestions
与textVisiblePassword
作为的inputType。我只是text
像尝试inputType
其他答案一样尝试了此操作,但这并没有任何区别,我也不想在键盘上有任何建议。
至于这个侦听器,我设法做到了,尽管有点不客气,因为action id
回来了IME_ACTION_UNSPECIFIED
,所以我只是处理了这个。可以在这里看到:
et_letter_entry.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_UNSPECIFIED ) {
preformSearch();
return true;
}
return false;
}
});
我目前有一个换行的图标,而不是search
搜索图标。
android:imeOptions="search"
在我看来,为什么xml似乎没有受到影响?
为什么输入按钮显示换行图标?
为什么操作ID返回未指定?
谢谢
去掉
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"
从您EditText
那里,它将解决您的问题。
冲突是由于android:digits
设置的。在这种情况下,默认情况下android:inputType
设置为numeric
忽略您android:inputType="text|textNoSuggestions|textVisiblePassword"
在xml中输入there()的内容,从而使您android:imeOptions="actionSearch"
无关紧要。
希望能帮助到你。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句