I'm trying to make a spinner with an array that I retrieve from a database, here goes the code I'm trying to use:
Unit unit;
int idx = 1;
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(this,
android.R.layout.simple_spinner_item, new Unit[] {
unit = connector.getUnit(idx);
while (connector.getUnit(idx) != null){
new Unit(unit.getunitID(), unit.getunitTypeID(), unit.getorganizationID(), unit.getunitName(), unit.getunitAddress());
unit = connector.getUnit(idx);
idx++;
}
});
connector.getUnit(idx) basically retrieves a Unit object from the database, will return a null value if there are not more units to retrieve. The compiler is complaining in:
unit = connector.getUnit(idx);
as "Syntax error, insert ")" to complete VariableInitializer"
and:
idx++;
as "Syntax error, insert "}" to complete Block"
I think that would be the right code to do what I want to, but somehow I can't manage to make it work, any idea?
Thanks in advance