How can I convert an ArrayAdapter of static data into a CursorAdapter for using Suggestion Listener in SearchView?
I h
That's strange SearchView.setSuggestionsAdapter accepts CursorAdapter only.
You could create MatrixCursor and fill it with data from String array. I hope you have small data collection.
Then pass the cursor to CursorAdapter.
String[] columnNames = {"_id","text"}
MatrixCursor cursor = new MatrixCursor(columnNames);
String[] array = getResources().getStringArray(R.array.allStrings); //if strings are in resources
String[] temp = new String[2];
int id = 0;
for(String item : array){
temp[0] = Integer.toString(id++);
temp[1] = item;
cursor.addRow(temp);
}
String[] from = {"text"};
int[] to = {R.id.name_entry};
busStopCursorAdapter = new SimpleCursorAdapter(context, R.layout.listentry, cursor, from, to);