Reputation: 10584
I have a search functionality in my application. I am fetching the results based on keywords submitted by user. How do I use listview to show results of the search query in a listview? This is my first time in using listview, any pointers, tutorials will be helpful.
Upvotes: 0
Views: 159
Reputation: 1217
Try to use AutoCompleteTextView.This will filter the list of items at the time of entering the text in to the AutoCompleteTextView field.
or
Use this.This will help you to add the listview in the LinearLayout.When the user press the any one of the alphabet this will filter the List items
ListView lv = new ListView(this);
lv.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, Your_array));
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String str_item = Your_array[position];
Toast.makeText(Your_Class_Name.this,str_item, 10).show();
}
});
Upvotes: 1
Reputation: 4147
I think searchable dictionary example is where you should start from. Code and other details are at http://developer.android.com/resources/samples/SearchableDictionary/index.html
Upvotes: 1