1
我正在瀏覽Google Android Developer網站上的基本教程Retrieving a List of Contacts。 科:匹配任何類型。排序CONTENT_FILTER_URI結果
我已經設置好了我的列表視圖,它顯示了預期的搜索結果,除了我想按顯示名稱(Contacts.DISPLAY_NAME_PRIMARY)排序。目前這只是一個看似隨意的混亂。
有問題的代碼如下:
@Override
public Loader<Cursor> onCreateLoader(int loaderId, Bundle args) {
/*
* Appends the search string to the base URI. Always
* encode search strings to ensure they're in proper
* format.
*/
Uri contentUri = Uri.withAppendedPath(
Contacts.CONTENT_FILTER_URI,
Uri.encode(mSearchString));
// Starts the query
return new CursorLoader(
getActivity(),
contentUri,
PROJECTION,
null,
null,
Contacts.DISPLAY_NAME_PRIMARY // <- SORT THIS, PLEASE!
);
}
當我使用Contacts.CONTENT_URI我的contentUri顯示所有聯繫人,排序工作正常預期。
爲什麼它不適用於過濾結果?