I have tried the highly popular answer suggested here
Although this hasn't worked for me like it seems to have for the other users. Perhaps it is outdated or I have something conflicting in my code.
Here is the xml for my 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" />
As you can see I have the android:imeOptions="search" & android:inputType="text"
along with textNoSuggestions
& textVisiblePassword
as the inputType. I have tried this with only text
as the inputType
like the other answer suggested but this didn't make any difference and I don't want any suggestions on the keyboard.
As for this listener I managed to get that working although in a bit of a hacky way because the action id
is coming back as IME_ACTION_UNSPECIFIED
, So I just handled this instead. This can be seen here:
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;
}
});
I've currently got an icon for a new line rather than search
or a search icon.
Why doesn't the xml seem to be affected by android:imeOptions="search"
in my case?
Why is the enter button displaying a new line icon?
Why is the action id returning as unspecified?
Thanks