작동하는 검색 위젯이 있고 검색 기록 제안을 추가하고 싶습니다. 안드로이드 튜토리얼 (http://developer.android.com/guide/topics/search/adding-recent-query-suggestions.html)을 따라 가며 검색이 진행되는 동안 제안 사항이 표시되지 않습니다. 여기 내 코드입니다 :Android SearchRecentSuggestions - SearchView에 입력 할 때 제안 사항이 표시되지 않습니다.
컨텐츠 제공 업체
<provider android:name=".SearchHistoryProvider" android:authorities="com.mypackage.SearchHistoryProvider"> </provider>
검색 가능한 구성
<?xml version="1.0" encoding="utf-8"?> <searchable xmlns:android="http://schemas.android.com/apk/res/android" android:label="@string/app_name" android:hint="@string/search_hint" android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" android:searchSuggestAuthority="com.mypackage.SearchHistoryProvider" android:searchSuggestSelection=" ?"> </searchable>
매니페스트 제공자를 선언
package com.mypackage; import android.content.SearchRecentSuggestionsProvider; public class SearchHistoryProvider extends SearchRecentSuggestionsProvider { public final static String AUTHORITY = SearchHistoryProvider.class.getName(); public final static int MODE = DATABASE_MODE_QUERIES; public SearchHistoryProvider() { setupSuggestions(AUTHORITY, MODE); } }
제안이 실제로 표시되지 않습니다 제외하고 (내 검색 활동에서) 콘텐츠 공급자에 대한 쿼리를 저장
private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchHistoryProvider.AUTHORITY, SearchHistoryProvider.MODE); suggestions.saveRecentQuery(query, null); // Collapse the search view as a search is performed MenuItem searchItem = mMenu.findItem(R.id.search); SearchView searchView = (SearchView) mMenu.findItem(R.id.search).getActionView(); searchItem.collapseActionView(); searchView.setQuery("", false); // send the query to the global search activity for loading the data Intent globalSearchIntent = new Intent(this, GlobalSearchFragmentActivity.class); GroceryOTGUtils.copyIntentData(intent, globalSearchIntent); globalSearchIntent.putExtra(GlobalSearchFragmentActivity.GLOBAL_SEARCH, true); startActivity(globalSearchIntent); } }
모든 (검색이 내가 그들을 추가 이전과 같은 모양), 잘 작동합니다. 어떤 도움이라도 대단히 감사하겠습니다!
아, 문제가 해결되었습니다. Android 매니페스트 구성 (제공자의 이름)에서 실수였습니다. 현상금을 어떻게 제거 할 수 있습니까? –
@ Eng.Fouad 다른 사람들에게 현상금을 넣으면 현상금을 제거 할 수 없다! –
@ Eng.Fouad 중재자는 극단적 인 경우에 현상금을 환불 할 수 있습니다.이 게시물에 플래그를 지정하고 "기타"를 선택한 다음 사례를 맹세 할 수 있습니다. 아직 너무 늦지 않았습니다. :) –