11

ダイアログポップアップはここにあります

ポップアップビューの最後でオートコンプリートの結果が停止する方法は次のとおりです

結果をダイアログのビューを超えて親ビューにドロップダウンしたいと思います。それができない場合は、オートコンプリートで得られる結果の数を2つに制限したいと思います。

これは、ポップアップメニューのクリックリスナーにあります。

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);
4

2 に答える 2

15

このメソッドを使用してAutoCompleteTextView、xml のウィジェットのドロップダウンの高さを制限する必要があります。

android:dropDownHeight="size"

または、これを使用してプログラムで実行します

autoCompleteTextView.setDropDownHeight(int);

この助けを願っています。

于 2014-02-07T07:15:38.813 に答える
4

getCount()アイテムの部分の制限数については、次をオーバーライドできますArrayAdapter

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

これはフィルタリングにも機能します。

于 2012-11-12T07:54:47.440 に答える