I have a trouble. I'm working with Google Maps Api v2 and I created a basic toolbar like in Google Maps App. There I have an AutoCompleteTextBox on it.
The trouble is when I press the 'DONE' button (when the screen is in portrait mode), the actionId==0 and the KeyEvent==0, but when I press the labeled action button (when the screen is in landscape mode) it works, but the DONE button doesn't work.
In java code implementation I wrote:
autoCompleteTextView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = false;
if (actionId == EditorInfo.IME_ACTION_DONE) {
//Log.i("AutoCompleteTextView", "Evento onEditorAction ... ");
search();
handled = true;
}
Log.i("AutoCompleteTextView", "Evento onEditorAction ... " + actionId);
return handled;
}
});
And in the XML layout I used:
<AutoCompleteTextView
android:id="@+id/autoText"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginLeft="48dp"
android:layout_marginBottom="6dp"
android:layout_marginRight="6dp"
android:gravity="bottom"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/fontColorMenu"
style="@style/AutoCompleteTextViewAppTheme"
android:imeActionLabel="Buscar"
android:imeOptions="actionDone"
android:hint="Ingrese ciudad"
android:inputType="text"/>
So I don't know what is wrong, I am working with targetSdkVersion 22, with my Moto G on Android Lollipop and using Android Studio 1.1.0.
Yes you are right. Because you are using your own text "Buscar" instead of default "Done". To overcome your issue change EditorAction method code.
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = false;
if (actionId == event.ACTION_DOWN) {
search();
handled = true;
}
return handled;
}