11

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);
Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
Mitch D
  • 111
  • 1
  • 4

2 Answers2

17

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.

Nemo
  • 2,441
  • 2
  • 29
  • 63
i.n.e.f
  • 1,773
  • 13
  • 22
4

For the limiting number of items part: you can override getCount() of ArrayAdapter:

@Override
public int getCount() {
   return Math.min(2,super.getCount());
}

This works for filtering also.

S.D.
  • 29,290
  • 3
  • 79
  • 130
  • 3
    I should've been more clear. I'm not looking to limit the total results show to 2. I'm looking to limit the maximum amount of results shown at a time to two with scrolling of the rest. – Mitch D Nov 13 '12 at 03:59
  • 1
    yep, this is not what he was asking. This just limits the result number. – Alberto M Jul 18 '16 at 16:23