Android: How to bind spinner to custom object list?
- by niko
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!