Được rồi, tôi chỉ đang cố gắng tìm hiểu về cách sử dụng thông tin Liên hệ, nhưng tôi hơi bị kẹt. Tôi muốn có thể hiển thị một hình ảnh cho số liên lạc. Sử dụng đoạn mã sau mà tôi có, làm cách nào tôi có thể đặt ảnh cho liên hệ trong ImageView trong contact_entry?Nhận Ảnh từ một Số liên lạc
ListView contacts_list = (ListView) findViewById(R.id.contacts_list);
// Gets the URI of the db
Uri uri = ContactsContract.Contacts.CONTENT_URI;
// What to grab from the db
String[] projection = new String[] {
ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.PHOTO_ID
};
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
Cursor cursor = managedQuery(uri, projection, null, null, sortOrder);
String[] fields = new String[] {
ContactsContract.Data.DISPLAY_NAME
};
int[] values = {
R.id.contactEntryText
};
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.contact_entry, cursor,
fields, values);
contacts_list.setAdapter(adapter);
contact_entry.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="54px">
<ImageView
android:id="@+id/contactPhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_contact_picture_3"/>
<TextView
android:text="@+id/contactEntryText"
android:id="@+id/contactEntryText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
hãy thử điều này, Có thể điều này sẽ giúp bạn http://stackoverflow.com/a/38992166/4593930 –