I have a search view that has the suggestions populated by a MatrixCursor (because I already have an array of Strings). However I would like to get which item is being selected by the user. So far I am only able to get the position where the user has clicked on the suggestion list:
searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() {
@Override
public boolean onSuggestionClick(int position) {
String selectedItem = (String)mAdapter.getItem(position);
Log.e("search view", selectedItem);
return true;
}
However I have got an error: android.database.MatrixCursor cannot be cast to java.lang.String and I am not sure how to go around with it. Really appreciate for any kind of help.
If someone is still looking for the answer. Use this code.