Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to sort 2 lists at once in android
    text
    copied!<p>I have 2 lists one is names and other is numbers. When i sort names list its working fine but numbers are not matching with those names and this is my code</p> <pre><code>try { Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI; String[] projection = new String[] { ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER }; List&lt;String&gt; contactNames = new ArrayList&lt;String&gt;(); List&lt;String&gt; contactNumbers = new ArrayList&lt;String&gt;(); 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); } </code></pre> <p>Here contactNames and contactNumbers are givent to the listview lv_contacts_phone here I get only sorted names and numbers were not matched properly with the names please help me</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload