Автозаполнение с именем и номером, как в родном смс приложении Android

Я хочу добавитьAutoCompleteTextView в моем приложении и поиск контактов по имени и номеру, как это сделано в родном приложении SMS с Android. Я посмотрел в Интернете и попробовал немало вещей, но я хочу, чтобы мое приложение отображало его точно так же, как приложение для Android. Вот код, который я пытаюсь найти толькоDisplay_Name.

public class MakePayment extends Activity {
    private AutoCompleteTextView mAuto;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.makepayment);

        mAuto = (AutoCompleteTextView)findViewById(R.id.autoCompleteTextViewTest);
        ContentResolver content = getContentResolver();
        Cursor cursor = content.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                PEOPLE_PROJECTION, null, null, null);

        ContactListAdapter adapter = new ContactListAdapter(this, cursor);
        mAuto.setAdapter(adapter);
    }

     public static class ContactListAdapter extends CursorAdapter implements Filterable {
            public ContactListAdapter(Context context, Cursor c) {
                super(context, c);
                mContent = context.getContentResolver();
            }

            @Override
            public View newView(Context context, Cursor cursor, ViewGroup parent) {
                 final LayoutInflater inflater = LayoutInflater.from(context);
                    final TextView view = (TextView) inflater.inflate(
                            android.R.layout.simple_expandable_list_item_1, parent, false);
                    view.setText(cursor.getString(2));
                    return view;
            }        

            @Override
            public void bindView(View view, Context context, Cursor cursor) {
                ((TextView) view).setText(cursor.getString(2));

            }

            @Override
            public String convertToString(Cursor cursor) {
                return cursor.getString(2);
            }

            @Override
            public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
                if (getFilterQueryProvider() != null) {
                    return getFilterQueryProvider().runQuery(constraint);
                }

                StringBuilder buffer = null;
                String[] args = null;
                if (constraint != null) {
                    buffer = new StringBuilder();
                buffer.append("UPPER(");
                buffer.append(ContactsContract.Contacts.DISPLAY_NAME);
                buffer.append(") GLOB ?");
                    args = new String[] { constraint.toString().toUpperCase() + "*" };
                }

                return mContent.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, PEOPLE_PROJECTION,
                        buffer == null ? null : buffer.toString(), args,
                        null);
            }



            private ContentResolver mContent;           
        }

     private static final String[] PEOPLE_PROJECTION = new String[] {
            ContactsContract.Contacts._ID,
            ContactsContract.CommonDataKinds.Phone.NUMBER,
            ContactsContract.Contacts.DISPLAY_NAME,
        };

}

Как мне искать по телефонам? А затем отобразить это так: enter image description here

Ответы на вопрос(2)

Ваш ответ на вопрос