Android: How to bind spinner to custom object list?
Posted
by niko
on Stack Overflow
See other posts from Stack Overflow
or by niko
Published on 2009-10-26T14:45:09Z
Indexed on
2010/04/30
16:27 UTC
Read the original article
Hit count: 1262
Hi,
In the user interface there has to be a spinner which contains some names (the names are visible) and each name has its own ID (the IDs are not equal to display sequence). When the user selects the name from the list the variable currentID has to be changed.
The application contains the ArrayList
Where User is an object with ID and name:
public class User{
public int ID;
public String name;
}
What I don't know is how to create a spinner which displays the list of user's names and bind spinner items to IDs so when the spinner item is selected/changed the variable currentID is set to appropriate value.
I would appreciate if anyone could show the solution of the described problem or provide any link useful to solve the problem.
Thanks!
© Stack Overflow or respective owner