Making Selecting a search suggestion fill search field (#169)
This commit is contained in:
parent
7038437d05
commit
18fd3a2384
@ -24,6 +24,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.database.Cursor;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.SearchRecentSuggestions;
|
import android.provider.SearchRecentSuggestions;
|
||||||
|
|
||||||
@ -166,7 +167,27 @@ public class VideoListActivity extends CommonActivity {
|
|||||||
Log.d(TAG, "onDismiss: ");
|
Log.d(TAG, "onDismiss: ");
|
||||||
loadVideos(0, count, sort, filter);
|
loadVideos(0, count, sort, filter);
|
||||||
});
|
});
|
||||||
|
searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onSuggestionClick(int position) {
|
||||||
|
String suggestion = getSuggestion(position);
|
||||||
|
searchView.setQuery(suggestion, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSuggestion(int position) {
|
||||||
|
Cursor cursor = (Cursor) searchView.getSuggestionsAdapter().getItem(
|
||||||
|
position);
|
||||||
|
return cursor.getString(cursor
|
||||||
|
.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onSuggestionSelect(int position) {
|
||||||
|
/* Required to implement */
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user