Android SearchView with custom suggestions adapter Android SearchView with custom suggestions adapter sqlite sqlite

Android SearchView with custom suggestions adapter


The issue is that the adapter will show data with column names such as SUGGEST_COLUMN_TEXT_1. This is the column displayed in the search dropdown box. But your cursor uses the database column name *name" iin your case. So what you have to do is tell the adapter to match your database column with your adapter column. The way that I do this is create a HashMap with something like hashMap.put(name, name + " as " SearcgManager.SUGGEST_COLUMN_TEXT_1) then in SQLiteBuilder mSqliteBuilder yoou can do mSqliteBuilder.setProjectionMap(hashMap) prior to creating your cursor. I don't use the onQueryTextChange for search suggestions but use contentprovider along with searchable configuration file. But because the columns are not matched is whyI believe you are not seeing your suggestions in your list


The problem is that you provided a layout for the to field in the constructor for SimpleCursorAdapter(). You should instead provide a resource ID for a textview, such as android.R.id.text1.


I had a similar problem. It turned out that all I needed to do is to change the color of the text that is displayed in the listed entries. So I have it something like

<TextView        android:id="@+id/item"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:textColor="#FFF2FF"        />