I am working in android. i am trying to display name of university using listView.
my list view is looking like this.
Now i want to add a search bar on the top of this list view. if i press A in search bar then this list view should display all the name of university start with A , if i press some other character then according university name must be displayed.
Please tell me how can implement this. Is any way to make search bar in android. I have seen in iPhone, it works very efficiently in iPhone. Please help me how can make this search bar ?
Thank you in advance...
This may be the long way. but this is just an idea..
I think you have to create a layout xml file with one EditText
and ListView
. Inside activity you have to listen for textChange in EditText
and then probably you have to filter your ListAdapter
based on the text entered by the user and bind it with ListView
.
See the complete example here : http://www.androidpeople.com/android-listview-searchbox-sort-items
您可以在列表视图中使用setTextFilterEnabled(true)
。
I think this may help you to get an idea. http://developer.android.com/resources/tutorials/views/hello-autocomplete.html
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.