2

当使用带有自定义搜索建议的搜索界面时,有没有办法限制显示的建议数量?

谢谢!

4

1 回答 1

0

其实很简单。

首先在你的 中ContentProvider,定义一个变量来引用:

public static final String LIMIT_PARAMETER = "LIMIT";

在提供者的Cursor query@Override 中定义一些东西来保持你的极限值

String limit = uri.getQueryParameter(LIMIT_PARAMETER);

然后传递limitSqliteQueryBuilder

final Cursor cursor = queryBuilder.query(db, projection, selection,
        selectionArgs, null, null, sortOrder, limit);

然后,您可以像这样使用它contentResolver

getContentResolver().query( 
    SOME_CONTENT_URI.buildUpon().appendQueryParameter(
        YourContentProvider.LIMIT_PARAMETER, yourLimit).build(), 
    mSuggestionProjection, mSelection,
    filterArgArray, ORDER_BY );
于 2015-01-21T13:56:23.913 回答