listview的数据内容不会从选项菜单中更改?

时间:2014-04-28 09:58:44

标签: android listview menu

在我的代码中,我正在listview向我的应用程序提取收件箱邮件我想要的是我提供show view作为option menu项目来更改数据{{1}将显示ie(1)第一个视图是listview(2)All inbox messages will be displayed但是当我正在运行我的应用程序时,列表视图中没有显示任何内容。 谁能告诉我怎么做......

only messages from unknown no's will be displayed

选项菜单中的代码:

public void getInboxSms() {
    ContentResolver cr = getContentResolver();
    c = cr.query(Uri.parse("content://sms/inbox"), null, null, null, null);
    totalSMS = c.getCount();
    if (c.moveToFirst()) {
        for (int i = 0; i < totalSMS; i++) {

            Log.d("SMSss", "Contact number : "+ c.getString(c.getColumnIndexOrThrow("address"))+ "\n"
                            + "msg : " + c.getColumnIndexOrThrow("body")
                            + "\n"
                            + "Person : "
                            + getContactName(c.getString(c.getColumnIndexOrThrow("address"))));
            c.moveToNext();
        }
    }
}

public String getContactName(String phoneNumber) {
    ContentResolver cr = getApplicationContext().getContentResolver();
    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
            Uri.encode(phoneNumber));
     Cursor cursor = cr.query(uri,
            new String[] { PhoneLookup.DISPLAY_NAME }, null, null, null);
    if (cursor == null) {
        return null;
    }
    String contactName = null;
    if (cursor.moveToFirst()) {
        contactName = cursor.getString(cursor
                .getColumnIndex(PhoneLookup.DISPLAY_NAME));
    }
    if (cursor != null && !cursor.isClosed()) {
        cursor.close();
    }
    return contactName;
}

private List<SMSListModel> getModel() 
{
if(c.getCount()>0)
{
    for(int i=0;i<c.getCount();i++)
    {
        if(c.moveToPosition(i))
        {
            if(getContactName(c.getString(c.getColumnIndex("address"))) == null ){

                list.add(new SMSListModel(c.getString(c.getColumnIndex("address")),c.getString(c.getColumnIndex("body"))));
            }   
            }
    }
}
return list;        
}

1 个答案:

答案 0 :(得分:0)

您是否检查过Select_view数组在创建Dialog时是否有值?