title: add items to custom listview through spinner setOnItemSelectedListener
body: <p>I am trying to add items to custom listview when a spinner is selected using the following code but this is obviously not working. I don't know how to do it. Please help me below is what my little code</p>
  
  <pre><code>Spnchapter.setOnItemSelectedListener(new OnItemSelectedListener() 
      {
          @Override
          public void onItemSelected(AdapterView&lt;?&gt; parent,
                  View view, int pos, long id) 
          {                
              Toast.makeText(getApplicationContext(), Spnchapter.getSelectedItem().toString(),
                         Toast.LENGTH_LONG).show();
              generateData();             
          }
  
          @Override
          public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
              // TODO Auto-generated method stub
  
          }
      });
      // Spinner
  
  private ArrayList&lt;Item&gt; generateData()
  {
      ArrayList&lt;Item&gt; items = new ArrayList&lt;Item&gt;();
  
      int verseNumber = 1;
      ExternalDbOpenHelper dbOpenHelper = new ExternalDbOpenHelper(this, DB_NAME);
      database = dbOpenHelper.openDataBase();
  
      Cursor c = database.rawQuery("select * from friends where chapter = 1 ", null);
      c.moveToFirst();
      if(!c.isAfterLast()) 
      {
          do 
          {
              String name = c.getString(3);
              if(c.getString(2).length() == 0)
              {                   
                  items.add(new Item("", " " + name + " " + c.getString(5)));
              }
              if(!c.getString(2).equals(""))
              {
                  items.add(new Item(" " + Integer.toString(verseNumber++), "    " + name));                  
              }       
          } 
          while (c.moveToNext());
      }
      c.close();
      return items;
  }
  </code></pre>