我有一個列表視圖,其中有三個人來自聯繫人列表。我怎樣才能顯示這些人的電話號碼?找到基於名稱的電話號碼 - android
有人可以發表一個代碼嗎?
for (int i=0;i<list.size();i++)
{
Log.i("TAG","PHONE NO IS: "+ ......)---------phone number?
//list.get(i).getName() - is the contact list persons name.
CounterResolvercr=getCounterResolver();
Cursor cur= cr.query(ContactsContact.CONTENT_URI,null,null,null);
while (cur.moveToNext())
{
if (cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME))== list.get(i).getName())
{
String id= cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID);
Cursor pcur=cr.quesy(ContactsContact.CommonDataKinds.Phone.CONTENT_URI, null, ContactContract.CommonDataKInds.Phone.CONTACT_ID+"=?",new Strng[]{id},null);
while (pCur.moveToNext())
{
String number = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
Log.d(TAG,number);//IS NOT PRINTING ANYTHING WHY?!!!
}
pcur.close()
}
}
}
這是不可靠的......但如果你知道名稱的**類型**,你可以將它包含在選擇參數和查詢中。 – ngesh 2012-03-28 12:54:48
請清楚地提出問題。 – 2012-03-28 12:56:26
好吧,我已經把一些代碼 – user1222905 2012-03-28 13:07:09