Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Jason Losito
PLUS
Jason Losito
Courses Plus Student 8,865 Points

QAutoCompleteTextView that assigns the id and value from a MySQL database via JSON.

Hello Treehouse students and teachers,

Is it possible to assign an id to an AutoCompleteTextView item from a MySQL database?

I am able to grab the data I need (product_id and product_name) via JSON and was able to display the list in the AutoCompleteTextView. I want to assign the product id to the item id as swell but I do not know how to do it. I do not want to use a spinner is the list of products is very long.

Please help me on this one as I am stuck on this for a week now.

Regards, Jason Losito

David Axelrod
David Axelrod
36,073 Points

What you're working on sounds awesome. I just spend the past 20 minutes trying to find an answer on stackoverflow and the android docs. Im sure the answer is somewhere on the interwebs but I wasn't able to find it.

Maybe shoot a tweet over to our android teacher Ben Jakuben

Jason Losito
Jason Losito
Courses Plus Student 8,865 Points

Hi David,

Thanks. I was planning to use a Spinner but since the product entries will be thousands, AutoCompleteTextView is a good choice. But as I have said, I can't find the solution to my problem. An alternative for me is to use the product _name to database query but I know using the product id will be more efficient.

I will try and tweet Ben. I hope he replies. :)

Jason Losito
Jason Losito
Courses Plus Student 8,865 Points

I have temporarily used the product_name as the search parameter.