I have an action bar with a search widget in my ICS application. I want the user to be able to search for some of the materials that came with the application. Therefore, I want to use a search widget, displaying a list of results, which is updated when the user enters a new char (the same functionality as the Play Store). I implemented SearchView.OnQueryTextListener
in my activity and implemented two methods onQueryTextChange(String newText)
and onQueryTextSubmit(String query)
. In onQueryTextChange
I call my service, which returns values โโfor a typed sentence. But I have no plan how to display a list of offers. I read developer.android.com articles, but as I understand it, this is mainly for the old search implementation (<Honeycomb). In the examples of the search widget API, the sentences are applications installed on the system, served by SearchManager
. I did not find a tutorial or an example that covers this topic (custom suggestions in search widgets), does anyone know something like this?
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.search_menu, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); searchView.setOnQueryTextListener(this); return super.onCreateOptionsMenu(menu); } @Override public boolean onQueryTextChange(String newText) { Log.i(TAG, "Query = " + newText); if(newText.length() > 0){
I read that I need ContentProvider
extend ContentProvider
from SearchRecentSuggestionsProvider
, but I donโt know how I process and create this provider. I have a searchable.xml
called searchSuggestAuthority
for my empty content provider. In AnroidManifest, I added a search intent in MainActivity, added metadata, and added my provider. But I donโt know how to get my values โโin the Content Provider and display them as offers.
public class SuggentionsProvider extends SearchRecentSuggestionsProvider { public final static String AUTHORITY = "com.sap.hui.helper.SuggentionsProvider"; public final static int MODE = DATABASE_MODE_QUERIES; public SuggentionsProvider(){ setupSuggestions(AUTHORITY, MODE); } }
BR
mybecks
source share