Note that there are some explanatory texts on larger screens.

plurals
  1. POAlphabetIndexer not working with Custom ListView
    primarykey
    data
    text
    <p>I am using AlphabetIndexer, SectionIndexer, Custom CursorAdapter for a Customized ListView. following is the code for the same. But I am not able to see the Alphabets while scrolling the List. I also tried the following link <a href="https://stackoverflow.com/questions/4358106/how-to-combine-both-display-name-and-number-in-a-customized-cursoradapter">how to combine both DISPLAY_NAME and NUMBER in a customized CursorAdapter?</a></p> <pre><code>public class ContactListCustomCursorAdapter extends CursorAdapter implements SectionIndexer { private LayoutInflater inflater; private CursorsForContacts cursorsForContacts; private AlphabetIndexer alphabetIndexer; public ContactListCustomCursorAdapter(Context context, Cursor cursor) { super(context, cursor, true); inflater = LayoutInflater.from(context); cursorsForContacts = new CursorsForContacts(context); alphabetIndexer = new AlphabetIndexer( cursor, cursor.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME), " ABCDEFGHIJKLMNOPQRSTUVWXYZ"); //alphabetIndexer.setCursor(cursor); } @Override public void bindView(View view, Context context, Cursor cursor) { String contactId = setContactName(view, cursor); setContactPhoneNumbers(view, contactId); setContactEmails(view, contactId); } @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { final View view = inflater.inflate(R.layout.custom_contact_list_item, parent, false); return view; } private String setContactName(View view, Cursor cursor) { int username = cursor .getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME); TextView userName = (TextView) view.findViewById(R.id.userName); userName.setText(cursor.getString(username)); return cursor.getString(cursor .getColumnIndex(ContactsContract.Contacts._ID)); } private void setContactPhoneNumbers(View view, String contactId) { Cursor phoneCursor = cursorsForContacts.getPhoneNumberCursor(contactId); TextView phoneNumber = (TextView) view.findViewById(R.id.userNumber); while (phoneCursor.moveToNext()) { phoneNumber .setText(phoneCursor.getString(phoneCursor .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER))); } } private void setContactEmails(View view, String contactId) { Cursor emailCursor = cursorsForContacts.getEmailCursor(contactId); TextView userEmailId = (TextView) view.findViewById(R.id.userEmailId); while (emailCursor.moveToNext()) { userEmailId .setText(emailCursor.getString(emailCursor .getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA))); } } @Override public int getPositionForSection(int section) { return alphabetIndexer.getPositionForSection(section); } @Override public int getSectionForPosition(int position) { return alphabetIndexer.getSectionForPosition(position); } @Override public Object[] getSections() { return alphabetIndexer.getSections(); } } </code></pre> <p>Am I missing something?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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