I am trying to get the enter button to execute code in an AutoCompleteTextView
similar to what this user
asked. I have tried the following:
view.search_auto_complete.setOnKeyListener { v, keyCode, event ->
if (keyCode == KeyEvent.KEYCODE_ENTER && event.action == KeyEvent.ACTION_DOWN) {
println("entered")
}
false
}
this works if I press the enter key on my desktop computer but does not work for the android soft keyboard, I am thinking that what I think is the enter key isn't actually the enter key but some kind of newline key, so if someone knows how to change the keyboard or the code to reflect the AutoCompleteTextView
I would be very thankful. but I am not familiar with the android soft keyboard at all.
I am keeping this question up because I hope it can help someone.
the solution was to add android:inputType="text"
to the
<AutoCompleteTextView
android:inputType="text"
android:id="@+id/search_auto_complete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />