I have the following app architecture (generalized for simplification):
main Layout
consists of ActionBar
with custom View
and scrollable Tabs
, and a ViewPager
hosting multiple ListFragments
. Each ListFragment
has its own set of data (1 row = ImageView
+ TextView
) which is loaded from an SQLite database. In my ActionBar's
custom View
a have a "search" EditText
.
When the user starts typing something, I'd like to perform an "on-the-go" search in the database and display matching names (those names should be clickable) in form of a dropdown list. I saw some examples how to perform a search in a ListView
, but nothing related to database search.
So the question is: how to display database search results as dropdown list and refresh it anytime the user adds or removes a character?
You need to implement AutoCompleteTextView. This allows suggestions as the user is typing. You can bind the data to be searched for, using Adapters.
This should solve your problem.
An example that might be helpful can be found here.