title: Spinner only displaying one item from JSON
body: <p>I have a spinner that will display all of supplier's name that will come from JSON. I have retrieved JSON data, stored it in an arraylist and displays it. The problem is that it only displays one item. a recently added item.</p>
  
  <p>here is my code which contains the implementation for the spinner:</p>
  
  <pre><code>        @Override
      protected void onPostExecute(JSONObject json){
          if(json != null){
              try{
                  result = json.getJSONArray("supplier");
                  if(!result.toString().equals("[]")) {
                      for (int i = 0; i &lt; result.length(); i++) {
                          JSONObject source = result.getJSONObject(i);
                          String suppliers = source.getString("SupplierName");
                          //Toast.makeText(PurchaseOrder.this, "Suppliers: "+suppliers, Toast.LENGTH_SHORT).show();
                          spinnerArray =  new ArrayList&lt;String&gt;();
                          spinnerArray.add(suppliers);
  
                          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(
                                  PurchaseOrder.this, android.R.layout.simple_spinner_item, spinnerArray);
  
                          spinSupplier.setAdapter(adapter);
                      }
  
  
                  } else {
                      Toast.makeText(PurchaseOrder.this, "ERROR", Toast.LENGTH_SHORT).show();
                  }
  
              } catch (Exception e) {
                  e.fillInStackTrace();
              }
          } else if(json == null) {
              Toast.makeText(PurchaseOrder.this, "NULL", Toast.LENGTH_SHORT).show();
          } else {
              Toast.makeText(PurchaseOrder.this, "ERROR", Toast.LENGTH_SHORT).show();
          }
  
      }
  </code></pre>
  
  <p>JSON:</p>
  
  <pre><code>{"supplier":[{"SupplierID":"1","SupplierName":"Nike","Address":"161","City":"Caloocan","Region":"NCR","PostalCode":"1114","Phone":"0917123456","Email":"email@mail.com"},{"SupplierID":"2","SupplierName":"Adidas","Address":"36 C","City":"Quezon City","Region":"NCR","PostalCode":"1115","Phone":"7493857","Email":"email@email.com"},{"SupplierID":"3","SupplierName":"NIEK","Address":"","City":"Quezon City","Region":"ARMM","PostalCode":"1104","Phone":"709-2227","Email":"niekniekniek@gmail.com"}]}
  </code></pre>