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 6597111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:09:58+00:00 2026-05-25T18:09:58+00:00

I have just implemented an autocompletion for a textfield using an online webservice, based

  • 0

I have just implemented an autocompletion for a textfield using an online webservice, based on this answer on Stackoverflow:
ArrayAdapter is updated late from Webservice in AutoCompleteTextAdapter

Using an ArrayAdapter<User> implements Filterable, I have managed that the autocompletion suggests me entries as intended.
User is a Java Bean that contains information which is presented in the suggestion (age, name, …).

When I select a suggestion, the Autocomplete field is filled with the ‘wrong’ data – using the toString()method, instead of the ‘name’ property of the bean.

My Question is: Can I override (in the Adapter) a method which will allow me to specify how to convert the bean so that the correct property is returned for the AutoCompleteTextView?
(Ideally, User.toString() should not be changed)

Thx!

  • 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-05-25T18:09:59+00:00Added an answer on May 25, 2026 at 6:09 pm

    I have found another way:

    The method convertSelectionToString(Object selectedItem) in AutoCompleteTextView can be overridden by subclasses to allow for custom conversions. This way, no adjustment to the toString() method is required.

    This – it seems to me – has the advantage that the Filter can return not just a list of Strings but a list of custom objects, which can be used by getView(int position, View convertView, ViewGroup parent) of the adapter to construct “richer” suggestions.

    The obvious disadvantage is that it requires subclassing AutoCompleteTextView for every Filterresult type whose toString() method shall not be modified.

    @Override
    protected CharSequence convertSelectionToString(Object selectedItem) {
        if(selectedItem instanceof User){
            User u = (User) selectedItem;
            return u.getUsername();
        } else {
            return super.convertSelectionToString(selectedItem);
        }
    }
    

    Any comments on this?

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

Sidebar

Related Questions

I am developing a Silverlight app using VS2008 Express. I have just implemented a
I have just implemented Facebook Authentication on my website using Facebook JavaScript. If user
I have just got a task in a new project which is implemented using
I have just implemented these ToggleButtons using ControlTemplates that set the Image content according
I have just implemented WMD for my editor in an ASP.NET app. The problem
I just finished reading this post: https://developer.yahoo.com/performance/rules.html#flush and have already implemented a flush after
I'm just learning Qt with C++. I have successfully implemented signals and slots to
We're just getting into MVVM in WPF. We have implemented our ViewModels with 'strongly
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I

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.