Tôi đang viết 1 app android, chức năng của app này là lấy ra 4 thông tin (id, name, phone number, company name) của tất cả các contact được lưu trong address book của điện thoại Android. Sau đó hiển thị các thông tin này trong 1 list view. Tôi sử dụng Cursorloader để lấy toàn bộ contact, sau đó setAdapter cho listview.

Hiện tại tôi đã lấy được 3 thông tin đầu tiên, ngoại trừ company name của contact đó. Khi tôi ghi giá trị của 4 thông tin này vào Logcat để, tôi phát hiện ra giá trị của company name và phone number là giống nhau hoàn toàn.

Ví dụ:
id: 1
name: Pakapun
phone: 01666777777
company: 01666777777


đó là tất cả vấn đề tôi gặp phải. Sau đây là code của app:


Mã:
package com.addressbook; import android.app.ListActivity;import android.app.LoaderManager;import android.content.CursorLoader;import android.content.Loader;import android.database.Cursor;import android.os.Bundle;import android.provider.ContactsContract;import android.support.v4.widget.SimpleCursorAdapter;import android.widget.ListView;import android.widget.TextView; public class MainActivity extends ListActivity implements LoaderManager.LoaderCallbacks<Cursor>{    protected TextView contactId;    protected ListView lv;     SimpleCursorAdapter mAdapter;     static final String[] PROJECTION = new String[] {            ContactsContract.CommonDataKinds.Phone._ID,            ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,            ContactsContract.CommonDataKinds.Phone.NUMBER,            ContactsContract.CommonDataKinds.Organization.COMPANY};            //ContactsContract.CommonDataKinds.Organization.DATA};     static final String SELECTION = "("+             ContactsContract.CommonDataKinds.Phone._ID + " NOTNULL AND " +             ContactsContract.CommonDataKinds.Phone._ID + " != '' )";      @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);                String[] fromColumns = {ContactsContract.CommonDataKinds.Phone._ID,                                ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,                                ContactsContract.CommonDataKinds.Phone.NUMBER,                                ContactsContract.CommonDataKinds.Organization.COMPANY};            int[] toViews = {       R.id.contactId,                                R.id.contactName,                                R.id.phone,                                R.id.company};            mAdapter = new SimpleCursorAdapter(this,                 R.layout.view_contact_entry, null,                fromColumns, toViews, 0);            setListAdapter(mAdapter);        getLoaderManager().initLoader(0, null, this);    }        public Loader<Cursor> onCreateLoader(int id, Bundle args) {        return new CursorLoader(this,ContactsContract.CommonDataKinds.Phone.CONTENT_URI,                    PROJECTION, null, null, "DISPLAY_NAME ASC");               }        public void onLoadFinished(Loader<Cursor> loader, Cursor data) {        mAdapter.swapCursor(data);    }        public void onLoaderReset(Loader<Cursor> loader) {        mAdapter.swapCursor(null);    }}
Còn đây là code XML của 1 item được hiển thị trên listview:


Mã:
<?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="wrap_content"    android:paddingTop="5dp"    android:paddingBottom="5dp"    android:paddingLeft="15sp"    android:orientation="horizontal" >        <ImageView        android:id="@+id/avatar"        android:layout_width="50dip"        android:layout_height="50dip"        android:       android:scaleType="fitXY"        android:src="@drawable/ic_launcher" />        <LinearLayout        android:layout_width="fill_parent"        android:layout_height="fill_parent"        android:gravity="center_vertical"        android:orientation="vertical" >             <TextView            android:id="@+id/contactId"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:visibility="gone" />            <TextView            android:id="@+id/phone"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:visibility="gone" />                <TextView               android:id="@+id/contactName"               android:layout_width="fill_parent"               android:layout_height="wrap_content"               android:textAllCaps="true"               android:textColor="#111"               android:paddingLeft="6dip" />           <TextView               android:id="@+id/company"               android:layout_width="fill_parent"               android:layout_height="wrap_content"               android:textStyle="italic"               android:textColor="#111"               android:paddingLeft="6dip" />       </LinearLayout>  </LinearLayout>
Mong các bác góp ý, tìm lỗi và cho tôi ý kiến hỗ trợ với.