Is there a way to limit the number of displayed suggestions, when using the search interface with custom search suggestion?
Thanks!
Is there a way to limit the number of displayed suggestions, when using the search interface with custom search suggestion?
Thanks!
It's very simple actually.
Firstly in your ContentProvider
, define a variable to have a reference to:
public static final String LIMIT_PARAMETER = "LIMIT";
In your Cursor query
@Override of the provider define something to hold your limit value
String limit = uri.getQueryParameter(LIMIT_PARAMETER);
Then pass the limit
to the SqliteQueryBuilder
:
final Cursor cursor = queryBuilder.query(db, projection, selection,
selectionArgs, null, null, sortOrder, limit);
You can then use it with a contentResolver
like so:
getContentResolver().query(
SOME_CONTENT_URI.buildUpon().appendQueryParameter(
YourContentProvider.LIMIT_PARAMETER, yourLimit).build(),
mSuggestionProjection, mSelection,
filterArgArray, ORDER_BY );