Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selection list cut off in AutoCompleteTextView in Dialog

Tags:

android

I have a dialog window that covers 1/3 of the entire screen height and is displayed on top of my activity. The dialog holds two AutoCompleteTextView fields.

The problem I'm facing is that when the user starts typing something into the AutoCompleteTextView, the list with all suggestions only shows up to the bottom end of the dialog, but doesn't go beyond that even the list is longer. It looks like it's cut off. (screenshot left)

Only after I long-press an item from the suggestion list, the list will be shown in full length. (screenshot right)

Screenhot is at: http://img704.imageshack.us/i/dialogdropdown.png/ screenshot http://img704.imageshack.us/img704/1893/dialogdropdown.png

How to fix this behaviour so that the list shows in full length right from the beginning, when the user starts typing something?

Code-wise there's nothing special, all I do is:

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.getContext(), R.layout.nav_route_autocomplete_row, locStrings);        
AutoCompleteTextView txtStartPos = (AutoCompleteTextView) findViewById(R.id.txtStartPos);
txtStartPos.setAdapter(adapter);
...

One workaround idea is to somehow dispatch a motion event to simulate a touch (but then not selecting though) one of the list items. Any concrete idea in code for a solution, anybody?

like image 699
Mathias Conradt Avatar asked Jul 18 '10 03:07

Mathias Conradt


3 Answers

Right now I'm assuming it's a bug, which I already filed here: http://code.google.com/p/android/issues/detail?id=9917

But if anybody knows a solution to this, I'd greatly appreciate it and would be glad to trade it for some bounty points.

Edit:

One workaround that came to my mind is now to extend the dialog to the very bottom of the screen but leave the background transparent, so it looks the same as now, but actually has a height that wouldn't cut off the list. I will give that a try...

like image 136
Mathias Conradt Avatar answered Nov 15 '22 02:11

Mathias Conradt


Not long ago i faced this problem. I had small dialog with AutoCompleteTextView, which had more than 10 items in Drop Down list. This list was cutted. My solution was:
Place some empty View in my Dialog layout file with parameters

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
<!--
Some Views placed here
-->
       <View
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="invisible" />

</LinearLayout>

It made my little dialog like a full screen dialog, but actualy that "tail" wasn't showed, and my DropDown wasn't cutted at all, cause it had enough place to show list items from DropDown.

like image 30
Procurares Avatar answered Nov 15 '22 04:11

Procurares


if (yourlist.size() > 5) {
    yourtextview.setDropDownHeight(562);
} else {
    yourtextview.setDropDownHeight(anytextview.getHeight() * yourlist.size());
}

//Workaround ->  Write this condition under on click and on focus change of your autocomplete text view 
like image 22
kartik_g Avatar answered Nov 15 '22 02:11

kartik_g