1

I followed the AutoCompleteTextView tutorial exactly. The layout gets wrong when a soft keyboard is involved.

enter image description here

After tapping inside the dropdown (to select or scroll), the layout is broken:

enter image description here

I tried various combinations of attributes on the AutoCompleteTextView but none seems to work. I also tried setting windowSoftInputMode. The dropdown always pops up above the textbox, and stays there forever.

In landscape orientation, the layout is OK:

enter image description here

Is the standard autocomplete useless? Should I use a different one / write my own?

The code I used is the following:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:padding="5dp">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Country" />
    <AutoCompleteTextView android:id="@+id/autocomplete_country"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"/>
</LinearLayout>

MainActivity.java:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    AutoCompleteTextView textView = (AutoCompleteTextView)  findViewById(R.id.autocomplete_country);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES);
    textView.setAdapter(adapter);
}
Martin Konicek
  • 39,126
  • 20
  • 90
  • 98

1 Answers1

0

Instead of using AutoCompleteTextView, I used EditText and a ListView as shown here.

Community
  • 1
  • 1
Martin Konicek
  • 39,126
  • 20
  • 90
  • 98