How to use a while loop to build a stringarray and use it as a list
<p>I am writing an app for fellow students, and I am parsing information from a website. I paid a guy to write the parser but did a poor job and he wants more money to help anymore. So im trying to fix it myself.</p>

<p>There is the extractor that grabs the xml info, how the gentlemen had it, was he called it in the main.java like this.</p>

<pre><code>      Content1 = extractor.BusRoutes.get(1);
      Content2 = extractor.BusRoutes.get(2);
      Content3 = extractor.BusRoutes.get(3);
</code></pre>

<p>But there is 30+ buses, and to me, that is not a solid idea. So I tried to do a while loop and an array in order to build the list and make it a list in android. </p>

<pre><code> public class BusRoutes extends ListActivity   {

TransitXMLExtractor extractor;


public String[] busroutearray()
{
    extractor = new TransitXMLExtractor();
    String[] busroutearray = new String[40];    
    int n = 0;
    while(n != (busroutearray.length - 1)){
    busroutearray[n] = extractor.BusRoutes.get(n);
    n++;
}
return busroutearray;
}








/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setListAdapter(new ArrayAdapter&lt;String&gt;(this,      android.R.layout.simple_list_item_1, busroutearray()));
    getListView().setTextFilterEnabled(true);
}
</code></pre>

<p>bus when i launch it, i always get a forced quit.</p>

<p>edit, the n++ was there before, but got deleted while changing up the code, but with the n++ it still has same effect. </p>
