1

I am using the following searchable xml for autosuggesting options when user types a contact name in the SearchView.

<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/find_contact"
android:hint="@string/find_contact"
android:gravity="center"
android:includeInGlobalSearch="true"
android:queryAfterZeroResults="true"
android:searchMode="queryRewriteFromText"
android:searchSettingsDescription="@string/find_contact"
android:searchSuggestAuthority="com.android.contacts"
android:searchSuggestIntentAction="android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"
android:searchSuggestIntentData="content://com.android.contacts/contacts/lookup" >

<!-- allow green action key for search-bar and per-suggestion clicks -->
<actionkey
    android:keycode="KEYCODE_CALL"
    android:queryActionMsg="call"
    android:suggestActionMsg="call" />

I am using the android.support.v7.widget.SearchView. Right now, as I type the name of the contact I am searching, only the name and the contact's image (if exists) show up in the suggestions list. How to display the contact number, as well as the type of contact (work, home, mobile etc), in the suggestions list, for each suggestion?

SoulRayder
  • 5,072
  • 6
  • 47
  • 93

1 Answers1

0

You should avoid using the android:searchSuggestIntentData to make the search, and do it yourself, then you can control the query itself, as well as the suggestions adapter.

See official tutorials:

  1. https://developer.android.com/guide/topics/search/index.html
  2. https://developer.android.com/guide/topics/search/adding-custom-suggestions.html
marmor
  • 27,641
  • 11
  • 107
  • 150