Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8743655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:43:00+00:00 2026-06-13T11:43:00+00:00

I wanted to use AutoCompleteTextView in my android application.I know how to use it

  • 0

I wanted to use AutoCompleteTextView in my android application.I know how to use it with simple array of Strings, but I wanted AutoCompleteTextView to use list of Objects to perform completion.My code for this is following:

ACTIVITY CODE

public void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.search);

        initialize();
        ArrayAdapter<Student> adapter = new ArrayAdapter<Student>(this,
                R.layout.dropdown_list_item, GetAllStudentsList());

        searchBox.setAdapter(adapter);
        searchBox.setThreshold(THRESHOLD_VALUE);
        searchBox.setTextColor(Color.BLACK);
}

searchBox.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view,
                int position, long arg3) {
                     //Here i will grab the Student object that user selected from drop-down

        }

    });

public ArrayList<Movies> GetAllStudentsList() {

//This method returns a ArrayList of <Student> type objects
}

Student class Object has information regarding a student which is ID,NAME,ADDRESS,MARKS.

I know AutoCompleteTextView needs an array of String type object to perform search operation.In my case I want AutoCompleteTextView to use my ArrayList to perform completion on the basis of Student object field NAME.I dont know how should I specify AutoCompleteTextView to use NAME field of Student object.Please help me providing any Link or a small example.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:43:01+00:00Added an answer on June 13, 2026 at 11:43 am

    Two ways:

    1. Override toString() in Student class and make it return name.
      You can get the object that was selected with the following code:

       public static class Student {
      
          private String name;
      
              public Student(String name) {
                  this.name = name;
              }
      
              @Override
              public String toString() {
                  return name;
              }
      
          }
      
      AutoCompleteTextView tv = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
      final ArrayList<Student> list = new ArrayList<MainActivity.Student>();
      list.add(new Student("Viru"));
      list.add(new Student("Gauti"));
      ArrayAdapter<Student> adapter = new ArrayAdapter<MainActivity.Student>(
              this, android.R.layout.simple_dropdown_item_1line, list);
      tv.setAdapter(adapter);
      
      tv.setOnItemClickListener(new OnItemClickListener() {
      
          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                  long arg3) {
              Student selected = (Student) arg0.getAdapter().getItem(arg2);
              Toast.makeText(MainActivity.this,
                      "Clicked " + arg2 + " name: " + selected.name,
                      Toast.LENGTH_SHORT).show();
          }
      });
      
    2. Implement a custom adapter (by extending BaseAdapter class or ArrayAdapter<Student> class) Check this tutorial : http://www.ezzylearning.com/tutorial.aspx?tid=1763429

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to use the currentStateChange event in my application but whatever code being
i wanted to use my java code as beanshell script but beanshell throws Exception
I wanted to use nested SqlDataReader in the code below but I couldn't make
I wanted to use 6 different textures on a cube, one per side, but
I wanted to use winreg module of python for working with windows registry. But
I wanted to use full width stripe on my footer, but aparently it doesen't
I wanted to use JET (Java Emitter Templates) in my Netbeans projects, but had
I wanted to use monotouch, but unfortunately I don't have $400 to spend. So
I wanted to use opencv library in a mex function but it just kept
I wanted to use boost::thread in my program, but get the following compiler error

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.