限制搜索建议的数量,Android [英] Limiting the number of search suggestions, android
本文介绍了限制搜索建议的数量,Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在使用带有自定义搜索建议的搜索界面时,是否可以限制显示建议的数量?
Is there a way to limit the number of displayed suggestions, when using the search interface with custom search suggestion?
谢谢!
推荐答案
实际上非常简单.
首先在您的ContentProvider
中,定义一个变量以引用:
Firstly in your ContentProvider
, define a variable to have a reference to:
public static final String LIMIT_PARAMETER = "LIMIT";
在提供者的Cursor query
@Override中定义一些内容来保存您的极限值
In your Cursor query
@Override of the provider define something to hold your limit value
String limit = uri.getQueryParameter(LIMIT_PARAMETER);
然后将limit
传递给SqliteQueryBuilder
:
final Cursor cursor = queryBuilder.query(db, projection, selection,
selectionArgs, null, null, sortOrder, limit);
然后可以将其与contentResolver
一起使用,如下所示:
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 );
这篇关于限制搜索建议的数量,Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文