I have a custom ListView set up in my app.
I am not sure how or if it's possible to do but I want to know how can I have the Android search icon to allow user to search within the ListView. So as the search becomes relevant, the ListView scrolls to that position and changes the background drawable.
I am looking to implement the search inside the ActionBar like this:
You need to implement the content provider component for your application. The "private" content provider will allow you to do "custom search" like you desire. As per documentation:
However, you do need your own provider to provide custom search suggestions in your own application.
The NotePad example can provide you with a good starting point on implementing a "private" content provider. By "private", i mean that you are not sharing the ListView data with any other app or process running on your device or remotely.
HTH
Filter
simply by implements Filter
to your ListView
adapter. performFiltering(CharSequence constraint)
method. SearchView
query text listeners. ListView
with filtered results. Or get position of relevant item inside the Adapter data, and scroll using mListView.smoothScrollToPosition(int position)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.