Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can implement search bar in android?

Tags:

android

I am working in android. i am trying to display name of university using listView.

my list view is looking like this. enter image description here

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...

like image 563
Pushpendra Kuntal Avatar asked May 24 '26 17:05

Pushpendra Kuntal


1 Answers

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 ListAdapterbased 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

like image 83
Kartik Domadiya Avatar answered May 27 '26 08:05

Kartik Domadiya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!