How to inflate setListAdapter into main layout?
<p>I am trying to create a list of businesses grabbed from a server and display them beneath the search box in a listview.</p>

<p>I am using setListAdapter to call my arrayAdapter class that I send the array to.  When I run the code it creates a new screen with the resuts in. I want the results on the same screen.</p>

<p>Here is my main layout:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#FF9900"
android:textColor="#000000"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"&gt;

    &lt;ImageView  
    android:layout_width="fill_parent" 
    android:layout_height="60px" 

    android:scaleType="fitXY"
    android:src="@drawable/logo" /&gt;

&lt;RelativeLayout  android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:id="@+id/rel1" android:gravity="right"&gt;
    &lt;AutoCompleteTextView android:id="@+id/autocomplete_classif"
        android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerInParent="true"/&gt;
    &lt;Button android:id="@+id/button1" android:text="Search" android:onClick="myClickHandler" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentRight="true"&gt;&lt;/Button&gt;

&lt;/RelativeLayout&gt;


&lt;EditText android:layout_height="wrap_content" android:id="@+id/editText2" 
android:layout_gravity="center_horizontal" android:text="" android:layout_width="match_parent" android:visibility="gone"&gt;
&lt;/EditText&gt;
    &lt;TextView android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:id="@+id/mylocation"
    android:lines="1" android:textColor="#000000" android:gravity="center"
    android:scrollbars="vertical"&gt;
&lt;/TextView&gt;

&lt;ProgressBar android:id="@+id/progressBar1" android:layout_width="wrap_content" 
android:layout_gravity="center_horizontal" android:layout_height="wrap_content" 
style="?android:attr/progressBarStyleHorizontal" android:visibility="gone"&gt; &lt;/ProgressBar&gt;


    &lt;TextView android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:id="@+id/pagetext" android:lines="50"
        android:textColor="#000000"
        android:background="#CCCCCC"
        android:padding="5px"
        android:scrollbars="vertical"&gt;
    &lt;/TextView&gt;




&lt;/LinearLayout&gt;
</code></pre>

<p>Here is the layout I am inflating dynamincally:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:padding="10px"
    android:layout_height="140px" android:id="@+id/rlt_main"
    android:background="#FFFFFF"
    android:textColor="#000000"&gt;

    &lt;TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:id="@+id/bus_name"
        android:text="Name" &gt;&lt;/TextView&gt;

    &lt;TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/description" 
        android:layout_below="@+id/bus_name" android:layout_marginLeft="10px"&gt;&lt;/TextView&gt;

    &lt;TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/distance" 
        android:layout_below="@+id/description" android:layout_marginLeft="10px"&gt;&lt;/TextView&gt;

    &lt;TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/longitude" 
        android:layout_below="@+id/distance" android:layout_marginLeft="10px"&gt;&lt;/TextView&gt;

    &lt;ImageView android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_centerVertical="true"
        android:id="@+id/iv_forward" android:background="@drawable/forward_arrow"
        android:layout_alignParentRight="true"&gt;&lt;/ImageView&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p>This is how I collate the data and send it to my class:</p>

<pre><code>            if(found) {
            jArray = new JSONObject(result);
            JSONArray  jResult = jArray.getJSONArray("result");

            StringBuilder output = new StringBuilder();
            ArrayList&lt;ArrayList&lt;String&gt;&gt; varray = new ArrayList&lt;ArrayList&lt;String&gt;&gt;();
                for(int i=0;i &lt; jResult.length();i++){    
                    JSONObject e = jResult.getJSONObject(i);

                    output.append(e.getString("webid") + "\n");

                    output.append(e.getString("webDistance") + "\n");

                    String longi = e.getString("webLongtitude");

                    String lati = e.getString("webLatitude");
                    String geoURI = String.format("geo:%s,%s", lati, longi);   
                    output.append(geoURI+"\n");

                    output.append("--------------------------------------------\n");
                    ArrayList&lt;String&gt; det = new ArrayList&lt;String&gt;();
                    det.add(e.getString("webEntryName"));
                    det.add(e.getString("webAddress"));
                    det.add(e.getString("webDistance"));
                    det.add(e.getString("webLongtitude"));
                    det.add(e.getString("webLatitude"));
                    varray.add(det);

                }

                setListAdapter(new busListAdapter(this, varray ));
                               }
</code></pre>

<p>And this is the arrayAdapter class:</p>

<pre><code>package com.dentons.dentonsweb;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class busListAdapter extends ArrayAdapter&lt;ArrayList&lt;String&gt;&gt; {
    private final Activity context;
    private final ArrayList&lt;ArrayList&lt;String&gt;&gt; varray;  
    private  ArrayList&lt;String&gt; varray2;

    public busListAdapter(DentonswebActivity context, ArrayList&lt;ArrayList&lt;String&gt;&gt; varray) {
        super(context, R.layout.business_list_item, varray);
        this.context = context;
        this.varray = varray;
    }



    // static to save the reference to the outer class and to avoid access to
    // any members of the containing class
    static class ViewHolder {
        public ImageView imageView;
        public TextView textView;
    }

    @Override

        public View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = context.getLayoutInflater();
            View row=inflater.inflate(R.layout.business_list_item, parent, false);

            TextView label=(TextView)row.findViewById(R.id.bus_name);
            TextView description=(TextView)row.findViewById(R.id.description);
            TextView distance=(TextView)row.findViewById(R.id.distance);
            TextView longitude=(TextView)row.findViewById(R.id.longitude);

        varray2 = varray.get(position);

        label.setText(varray2.get(0));
        description.setText(varray2.get(1));
        distance.setText(varray2.get(2));
        longitude.setText(varray2.get(3));

        return row;
    }
}
</code></pre>

<p>If I could find a way of telling the layout to inflate into main that would be great but I don't seem to be able to get a reference to main from within this class.  The best I have managed is for the inflation to happen within first screen but with no result.  I can't remember how I did this.  I am quite new to Java.</p>

<hr>

<p>This is the latest code:</p>

<p>This appear in main.xml
    TextView android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:id="@+id/pagetext" android:lines="50"
    android:textColor="#000000"
    android:background="#CCCCCC"
    android:padding="5px"
    android:scrollbars="vertical">
    /TextView></p>

<p>This is the new busListAdapter:</p>

<pre><code>package com.dentons.dentonsweb;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class busListAdapter extends ArrayAdapter&lt;ArrayList&lt;String&gt;&gt; {
    private final Activity context;
    private final ArrayList&lt;ArrayList&lt;String&gt;&gt; varray;  
    private  ArrayList&lt;String&gt; varray2;

    public busListAdapter(DentonswebActivity context, ArrayList&lt;ArrayList&lt;String&gt;&gt; varray) {
        super(context, R.layout.business_list_item, varray);
        this.context = context;
        this.varray = varray;
    }



    // static to save the reference to the outer class and to avoid access to
    // any members of the containing class
    static class ViewHolder {
        public ImageView imageView;
        public TextView textView;
    }

    @Override

        public View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = context.getLayoutInflater();
            View row=inflater.inflate(R.layout.business_list_item, parent, false);

            TextView label=(TextView)row.findViewById(R.id.bus_name);
            TextView description=(TextView)row.findViewById(R.id.description);
            TextView distance=(TextView)row.findViewById(R.id.distance);
            TextView longitude=(TextView)row.findViewById(R.id.longitude);

        varray2 = varray.get(position);

        label.setText(varray2.get(0));
        description.setText(varray2.get(1));
        distance.setText(varray2.get(2));
        longitude.setText(varray2.get(3));

        return row;
    }
}
</code></pre>

<p>This is the calling code:</p>

<pre><code>                ViewStub stub = (ViewStub) findViewById(R.id.viewStub1);
                stub.inflate();

                setListAdapter(new busListAdapter(this, varray ));
</code></pre>

<p>Any ideas why this is still opening on a blank page.</p>
