顯示聯絡人的頭像

2021-09-06 10:50:33 字數 390 閱讀 4914

顯示聯絡人頭像。判斷phone.photo_id是否為0,如果為0表示沒有設定頭像,就使用預設的聯絡人頭像,否則就使用使用者設定的頭像。

private void setdefaultphoto(viewholder holder, boolean bsim)

if (defaultsimphoto == null)

holder.photo.setimagebitmap(bsim ? defaultsimphoto : defaultphoto);

}在getview()方法中必須判斷。如果photoid為0時不呼叫setdefaultphoto(holder),會出現列表滑動時頭像迴圈重複的錯誤現象。

if(contact.getphotoid() != 0) else

獲取聯絡人頭像

首先設定需要獲取的資料 private static final string phones projection new string 其中上面的photo id可以判斷是否存在頭像,當大於0是表示存在頭像。通過下面查詢資料 contentresolver resolver mcontext.ge...

手機聯絡人資訊獲取 頭像,電話,姓名

需求 獲取本地通訊錄中的聯絡人資料 實現 通過系統定義好的常量去獲取聯絡人資料 public class contactsdao 返回的列名 string selection null 查詢的條件 string selectionargs null 查詢條件的引數 string sortorder ...

獲得聯絡人

注意在 後要加上 貌似從android2.0開始,聯絡人的api做了很大的調整。people介面由contactscontract.contacts代替。在聯絡人的 號碼中有很多種,如果只想獲得手機號碼。如下 cursor phones mcontext.getcontentresolver que...