filter listView包含带联系人的短信列表

时间:2014-06-25 03:54:52

标签: android listview android-listview

我有一个使用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);
        }
    });
之前listView只包含地址,但现在我已用实际联系号码映射它们,因此过滤器不再工作。我该如何返回查询以便它再次起作用

0 个答案:

没有答案