我在我的代碼中使用AutoCompleteTextView並使用SimpleCursorAdapter從數據庫加載列表。android autocompletetextview應該只顯示下拉相關的選項
AutoCompleteTextView cocktailIngredientView = (AutoCompleteTextView) findViewById(R.id.item);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_spinner_item, mCursor,
new String[] { "field" },
new int[] { android.R.id.text1 });
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
cocktailIngredientView.setAdapter(adapter);
cocktailIngredientView.setThreshold(0);
它正確地填充列表,但我有兩個問題:1。 我想這個列表進行排序 2.不管我進入,它顯示的完整列表。我希望它根據列表中的匹配模式進行過濾。例如如果列表包含值Page,Tools ...,那麼如果我在框中輸入T,下拉菜單應該只顯示工具。這個想法是在字符串文本的任何位置顯示包含輸入模式的選項。
這怎麼辦?請幫忙。
問候, 薩班
此外,當我選擇在下拉菜單中的任何項目下來就說明android.database.sqlite ... – Sapan 2011-04-16 09:53:43