I have created a dynamic ListView - how do I connect it to my XML layout file?
<p>Hi all and thank you for taking a look at this.  I have created a dynamic ListView using android's developer guide.  Currently, the ListView activity seems to display itself on screen without the need for an XML file or setContentView...which is a problem.</p>

<p>I would like to use an XML layout, so I can go and add other Views to the screen, rather than dedicating an entire Activity to just displaying the list.  I created an XML layout, that contains a blank ListView, amongst other things and I want my list to go into that allotted space...so my question:  How do I get my ListActivity to use my layout XML file?</p>

<pre><code>    public class MainList extends ListActivity {
    static SharedPreferences statusSettings;
    String jsonString;
    static JSONObject json;
    static JSONArray arrayTest;
    static int bob = 3;



    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        // TODO Auto-generated method stub
        super.onListItemClick(l, v, position, id);

        try {
            JSONObject e = arrayTest.getJSONObject(position);
            Intent intent = new Intent();
            intent.putExtra("clientName", e.getString("proj_name"));
            intent.putExtra("clientAddress", e.getString("c_address"));
            intent.putExtra("clientComments", e.getString("comments"));
            intent.putExtra("clientOrder", e.getString("order"));
            intent.setClass(MainList.this, ClientDetails.class);
            MainList.this.startActivity(intent);


        } catch (JSONException e) {
            // TODO Auto-generated catch block
            Log.e("JSON", "Problem creating object from array!");
            e.printStackTrace();
        }
    }

    private static class EfficientAdapter extends BaseAdapter {
        private LayoutInflater mInflater;


        public EfficientAdapter(Context context) {
            // Cache the LayoutInflate to avoid asking for a new one each time.
            mInflater = LayoutInflater.from(context);

        }

        public int getCount() {
            return arrayTest.length();

        }

        public Object getItem(int position) {
            return position;
        }

        public long getItemId(int position) {
            return position;
        }

        public View getView(int position, View convertView, ViewGroup parent) {

            ViewHolder holder;

            if (convertView == null) {
                convertView = mInflater.inflate(R.layout.mainlist, null);

                holder = new ViewHolder();
                holder.textName = (TextView) convertView.findViewById(R.id.tvMainName);
                holder.textAddress = (TextView) convertView.findViewById(R.id.tvMainAddress);


                convertView.setTag(holder);
            } else {

                holder = (ViewHolder) convertView.getTag();
            }


            JSONObject e;
            try {
                e = arrayTest.getJSONObject(position);
                holder.textName.setText(e.getString("proj_name"));
                holder.textAddress.setText(e.getString("c_address"));   


                switch (statusSettings.getInt(e.getString("order"), 0)){
                    case 1:
                        convertView.setBackgroundColor(0x00000000);
                        break;
                    case 2:
                        if(bob == 3){
                            convertView.setBackgroundColor(0xFFFF6600);
                            bob = 5;
                        }
                        break;
                    case 3:
                        convertView.setBackgroundColor(0xFF00CC00);
                        break;
                    case 4:
                        convertView.setBackgroundColor(0xFFCC0000);
                        break;
                }



            } catch (JSONException e1) {
                // TODO Auto-generated catch block
                Log.e("JSON", "Couldn't put one of JSON arrays into object");
                e1.printStackTrace();
            }



            return convertView;
        }

        static class ViewHolder {
            TextView textName;
            TextView textAddress;
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        jsonString = getIntent().getExtras().getString("jsonString");
        try {
            json = new JSONObject(jsonString);
            arrayTest = json.getJSONArray("client_list");
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            Log.e("JSON", "Couldn't create the JSON Array");
            e.printStackTrace();
        }
        setListAdapter(new EfficientAdapter(this));

    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        bob = 3;

        statusSettings = getSharedPreferences("status", 0);



        setListAdapter(new EfficientAdapter(this));
    }


}
</code></pre>

<p>XML File:</p>

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

    &lt;ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" android:layout_weight="1"&gt;
    &lt;/ListView&gt;


    &lt;Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" /&gt;

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

<p>The thing is, they create it without using any XML layout - I don't fully understand how, but I assume it has something to do with the LayoutInflater.  I tried:
convertView = mInflater.inflate(R.id.list, null);</p>

<p>instead of
convertView = mInflater.inflate(R.layout.mainlist, null);</p>

<p>and I placed setContentView(R.layout.test);
in my onCreate...but didn't work.  Any help you offer would be much appreciated, thank you!</p>
