I want to populate my Android spinner with data from a SQLite table. I already have a database controller, and these are returning custom objects.
Now what I have to do is to pop the spinner with this object so that the string field can not be found, but the id field for example: field ID and my table with day:
ID - Day 1 - Sunday
2 - Monday
3 - Tuesday ...
And in the day of the object, two properties (id and Name)
I want the spinner to be shown "Monday", but internally, store the id field '2' in an int variable. , Again to ask the database again with the selected values.
I think I have to do it with the adapter, but I do not know what I can do with this controller.
Thank you
SetAdapter . To populate your spinner through the ArrayAdapter & lt; T & gt;
.
Private list & lt; MyData & gt; Information; ... mySpinner.setAdapter & lt; MyData & gt; (New array adapter (getContext (), resId, data)); ... public class MyData {Private Int _id; Public MyData (int id) {this._id = id; } @ Override public string to string () {switch (this._id) {....}}}
No comments:
Post a Comment