我有一个使用SimpleCursorAdapter创建的listView。
lv = (ListView) findViewById(R.id.myList);
lv.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_INSET);
//Cursor c = this.getContentResolver().query(Uri.parse( "content://sms/conversations?simple=true"), null, null, null, "normalized_date desc" );
final Uri inboxURI = Uri.parse("content://mms-sms/conversations/");
final String[] reqCols = new String[] { "_id", "address", "body" };
final String[] projection = new String[]{"*"};
cr = getContentResolver();
Cursor c = cr.query(inboxURI, projection, null, null, Telephony.Sms.Inbox.DEFAULT_SORT_ORDER);
madapter = new simpleLayout(this, R.layout.list_row, c, new String[] { "body", "address" }, new int[] {R.id.text_msg, R.id.phone_number });
lv.setAdapter(madapter);
lv.setTextFilterEnabled(true);
我还在listview中添加了过滤器
madapter.setFilterQueryProvider(new FilterQueryProvider() {
public Cursor runQuery(CharSequence constraint) {
return getContentResolver().query(inboxURI, reqCols, "address" + " LIKE '" + constraint + "%'", null, null);
}
});