I have created a list view with multiple items in row. I have also created a search box above. I want to implement search functionality on the basis of particular fields of the list. How can I achieve this? Any help will be appreciated.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- What is the complexity of bisect algorithm?
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
Use below kind of method.
You can set a TextWatcher for your search box and change your Cursor on onTextChanged() on TextWatcher like Codes below :
for this, you first need to add an edittext, where you will type to filter data from the list,
then enable filteration in the list,
Then you need to add
TextChangeListener()
for the edittext,You have to use model, listview, and customadapter with filtering for this. I have created a demo for this.
Suppose you have a model named Product, and you are displaying its content in a custom listview where name and price are displayed in a textview. I mean in a custom row having two textviews, and you want to filter the list by one of the field of custom row. Here I have filtered with "name"
Screenshots:
Initial
Filtered
Source code
Model
Activity with custom adapter and listview
activity_main.xml
row.xml