Back to project page hello-srch2-android-sdk.
The source code is released under:
This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...
If you think the Android project hello-srch2-android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.srch2.android.demo.sqlite; /*w w w. j av a 2 s . c om*/ import android.app.Activity; import android.os.Bundle; import android.widget.ListView; import com.srch2.android.sdk.SRCH2Engine; import com.srch2.android.sdk.SearchResultsListener; public class SearchActivity extends Activity implements InstantSearchEditText.SearchInputEnteredObserver { DatabaseHelper mDatabaseHelper; SQLiteBookIndex mDatabaseIndexable; private ListView mSearchResultsListView; private SearchResultsAdapter mSearchResultsAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); mSearchResultsListView = (ListView) findViewById(R.id.lv_search_results); mSearchResultsAdapter = new SearchResultsAdapter(this); mSearchResultsListView.setAdapter(mSearchResultsAdapter); mDatabaseHelper = new DatabaseHelper(this); mDatabaseIndexable = new SQLiteBookIndex(mDatabaseHelper); } @Override protected void onResume() { super.onResume(); SRCH2Engine.setSQLiteIndexables(mDatabaseIndexable); SRCH2Engine.onResume(this, (SearchResultsListener) mSearchResultsAdapter, true); } @Override protected void onPause() { super.onPause(); SRCH2Engine.onPause(this); } @Override public void onNewSearchInput(String newSearchText) { // Pass the text of the InstantSearchEditText input field to the SRCH2Engine for doing // searches. A search could also be performed here specifically on mMovieIndex by calling // either mMovieIndex.search(newSearchText) or SRCH2Engine.searchIndex(MovieIndex.INDEX_NAME). SRCH2Engine.searchAllIndexes(newSearchText); } @Override public void onNewSearchInputIsBlank() { // Since the input field of the InstantSearchEditText is now empty, notify the // SRCH2Engine the search input is empty and clear the results of the list view by clearing // the data set of its backing adapter. SRCH2Engine.searchAllIndexes(""); mSearchResultsAdapter.clearDisplayedSearchResults(); } }