title: How to fill a Spinner from an array of arrays
body: <p>This is the error that i'm receiving.</p>
  
  <p>Null Pointer Exception
  11-06 19:03:34.050: WARN/System.err(5342):     at RetrievingAmazonXMLDataActivity.onCreate(RetrievingAmazonXMLDataActivity.java:88)</p>
  
  <pre><code>    for (int i = 0; i &lt; tokens.length; i++) {
                  String a = dumpTitles("ProductName", i);
                  element = a.split("!");
                  allProducts.add(element);
              }
  
             w =  (String[][])allProducts.toArray(new String[allProducts.size()][]);
  
  
      Spinner spinnerProducts = (Spinner) findViewById(R.id.spinner2);
              spinnerProducts.setOnItemSelectedListener(this);
  
  // **** error line below
  
  
       ArrayAdapter&lt;String&gt; productsArrayAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, productArrayToShow);
  
             productsArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
              spinnerProducts.setAdapter(productsArrayAdapter);
  
       public void onItemSelected(AdapterView&lt;?&gt; parent, View v, int position, long id)
          {
  
              try {
                  selected = parent.getItemAtPosition(position).toString();
  
  
                  productArrayToShow = w[position];
  
              } catch (Exception e) {}
          }
  </code></pre>