在我的android应用程序中,我打开了我的联系人列表,并在列表视图中显示它。但是当我在手机上测试这个应用的时候...有些接触需要重复5-6次。但在Emulator中,它工作得很好。我在下面给出我的代码..如果有情妇请帮帮我..
Cursor c = this.managedQuery(ContactsContract.Data.CONTENT_URI, null,
Data.MIMETYPE + "=?", // condition
new String[] {
ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE
}, // value
null);
ArrayList<Contact> contacts = new ArrayList<Contact>();
while (c.moveToNext())
{
int type = c.getInt(c.getColumnIndex(Phone.TYPE));
if (type == Phone.TYPE_MOBILE)
{
Contact con = new Contact(c.getString(c
.getColumnIndex(Contacts.DISPLAY_NAME)), c.getString(c
.getColumnIndex(Phone.NUMBER)));
contacts.add(con);
}
}
listView.setAdapter(new ContactsAdapter(this, contacts));发布于 2015-09-09 17:29:43
你确定所有的c(s)都是不同的吗?我的意思是,当你在智能手机中启动应用程序时,光标中的数据是正确的吗?没有重复的吗?
https://stackoverflow.com/questions/32475678
复制相似问题