我有 2 个列表,一个是名称,另一个是数字。当我对名称进行排序时,它的工作正常,但数字与这些名称不匹配,这是我的代码
try {
Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
String[] projection = new String[] {
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER };
List<String> contactNames = new ArrayList<String>();
List<String> contactNumbers = new ArrayList<String>();
Cursor people = getContentResolver().query(uri, projection, null,
null, null);
int indexName = people
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
int indexNumber = people
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
people.moveToFirst();
do {
String name = people.getString(indexName);
String number = people.getString(indexNumber);
contactNames.add(name);
contactNumbers.add(number);
} while (people.moveToNext());
PhoneContactsAdapter adapter = new PhoneContactsAdapter(context,
contactNames, contactNumbers, selectedContacts);
Collections.sort(contactNames);
adapter.notifyDataSetChanged();
lv_contacts_phone.setAdapter(adapter);
lv_contacts_phone.setFastScrollEnabled(true);
} catch (Exception e) {
System.out
.println("(SELECTFRIENDSACTIVITY)Selecting contacts from friends: "
+ e);
}
这里contactNames和contactNumbers被赋予listview lv_contacts_phone 这里我只得到排序的名字和数字与名字不正确匹配请帮助我