title: Setting an array in a spinner retrieved from a database
body: <p>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:</p>
  
  <pre><code>    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++;
                  }
                    });
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>unit = connector.getUnit(idx);
  </code></pre>
  
  <p>as <em>"Syntax error, insert ")" to complete VariableInitializer"</em></p>
  
  <p>and:</p>
  
  <pre><code>idx++;
  </code></pre>
  
  <p>as <em>"Syntax error, insert "}" to complete Block"</em></p>
  
  <p>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?</p>
  
  <p>Thanks in advance</p>