AutoCompleteTextView drop down height limited in dialog popup

Mitch D picture Mitch D · Nov 12, 2012 · Viewed 7.8k times · Source

The dialog pop-up is located here.

How the AutoComplete results stop at the end of the pop-up view is here.

I want the results to drop down past the dialog's view to the parent view. If I can't do that then I want to limit the number of results the AutoComplete gives me to two.

This is in my on click listener for the popup menu.

addDialog.setContentView(R.layout.shoppinglistadd);

/**Capture the AutoCompleteTextView widget*/
final AutoCompleteTextView autoCompleteTV 
  = (AutoCompleteTextView) addDialog.findViewById(R.id.productEnteredShop);
/**Fills the autocomplete with possibilities*/
String[] acArray = getResources().getStringArray(R.array.completeFoodsList);
/**Create a new ArrayAdapter and bind shoppinglistitem.xml to each list item*/
ArrayAdapter<String> autoCompleteAdapter 
  = new ArrayAdapter<String>(ShoppingList.this, R.layout.shoppinglistitem, acArray);
/**Associate the adapter with textView*/
autoCompleteTV.setAdapter(autoCompleteAdapter);

Answer

i.n.e.f picture i.n.e.f · Feb 7, 2014

You should use this method to limit the height of dropdown for AutoCompleteTextView widget in xml:

android:dropDownHeight="size"

Or use this to do programmatically

autoCompleteTextView.setDropDownHeight(int);

Hope this help.