我有一个AutoCompleteTextView,设置了光标可以在我的联系人中移动。问题是,虽然它可以正确地填充下拉菜单,但是在我输入后没有过滤出结果。
这是我光标和适配器的代码:
edt_Contact = (AutoCompleteTextView)findViewById(R.id.compose_edtContact);
cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
new String[] {Phone._ID, Phone.DISPLAY_NAME, Phone.NUMBER},
null,null,null);
startManagingCursor(cursor);
String[] from = new String[] { Phone.DISPLAY_NAME, Phone.NUMBER};
int[] to = new int[] { R.id.contact_name, R.id.contact_phoneNo};
adapter = new SimpleCursorAdapter(this, R.layout.simple_contact_textview, cursor, from, to);
edt_Contact.setAdapter(adapter);
以下是simple_contact_textview的xml代码:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:padding="5sp" android:paddingBottom="5sp" android:background="#FFFFFFFF">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/contact_name"
android:textColor="#FF000000"
android:textSize="20sp"
android:text="Name">
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/contact_phoneNo"
android:paddingLeft="10sp"
android:textColor="#FF000000"
android:textSize="20sp"
android:text="Number"
android:ellipsize="end">
</TextView>
</LinearLayout>
如何根据用户输入的内容筛选下拉菜单结果?比如,如果用户开始输入“and”,如何让“andrew”、“andy”和“mandy”出现?