我正在更改我的应用程序以使用 CursorLoader 而不是 startManagingCursor....
我有一个 AutoCompleteTextView、SimpleCursorAdapter,在我的 setFilterQueryProvider 实现中,在“runQuery”方法中有
mProdutoAdapter.setFilterQueryProvider(new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence constraint) {
Cursor cursor = mVendasDb.getProdutos(constraint.toString());
startManagingCursor(cursor);
return cursor;
}
});
如何更改此部分以使其与 CursorLoader 一起使用?
我是否应该丢弃 setQueryFilterProvider 并在 AutocompleteTextView 中使用 TextWatcher,然后调用 getLoaderManager().restartLoader(0, bundleFilter, this)???我不知道如何进行!
bundleFilter 会让文本来自 textwatcher。
用这个方法可以吗?在这种情况下最好这样做吗?
最佳答案
根据 android 开发者网站,这是一个很好的方法:
To discard your old data, you use restartLoader(). For example, this implementation of SearchView.OnQueryTextListener restarts the loader when the user's query changes. The loader needs to be restarted so that it can use the revised search filter to do a new query:
关于android - 带有 CursorLoader 的自动完成 TextView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17022282/