0

I am trying to implement Search feature for my android app.So, I am using AutoCompleteTextView. But, I am using ArrayList of custom Object.

This is my class.

public class Vehicle
{
 private String model,manufacturer;
}

Now, I have ArrayList of these Vehicle objects.

My question is, How to use these arraylist of objects to set as adapter for AutoCompleteTextView to search for model ??

Bharath
  • 3,001
  • 6
  • 32
  • 65

1 Answers1

2

How to use these arraylist of objects to set as adapter for AutoCompleteTextView to search for model ??

You don't say what do you show from the Vehicle class. The simplest way to setup the AutoCompletTextView is to use the simple ArrayAdapter(which will only show one value from Vehicle, the model) and also modify the Vehicle class like this:

public class Vehicle {
 private String model, manufacturer;

 @Override
 public String toString() {
    return model;
 }
}

Then simply give the list of custom Vehicle objects to the ArrayAdapter and set the adapter on the AutoCompleTextView.

For anything more complex then this you'll need to provide more details.

user
  • 86,916
  • 18
  • 197
  • 190