Android Views within Layouts
<p>Ok so I'm running into problems creating an app (force closing) and I think it has to do with the way I implemented the layout. So a few questions: First, I have a relative layout that includes a text input with a button next to it, a list view (still within the relative layout) and another button below that. This is my main xml file:</p>

<pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" &gt;

&lt;EditText
    android:id="@+id/edit_choice"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/Button1"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_toLeftOf="@+id/Button1"
    android:hint="@string/edit_choice" /&gt;

&lt;Button
    android:id="@+id/Button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:onClick="addString"
    android:text="@string/button_add" /&gt;

&lt;Button
    android:id="@+id/Button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="22dp"
    android:text="@string/button_random" /&gt;


&lt;ListView
    android:id="@+id/listView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/Button2"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/Button1"
    tools:listitem="@android:layout/simple_list_item_1" &gt;
&lt;/ListView&gt;

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

<p>Before I even changed anything in the .java files when I tried running this, only the text input and the 2 buttons appeared and the theme changed from Holo to Holo light. So I'm wondering if this works, I've only seen examples where the list view matches the parent layout completely.</p>

<p>My second question is how do I handle using the input to add values to the list view, can I do that in the main activity class or can I have another class to handle the list view and still reference the main layout. </p>

<p>This is my Main class:</p>

<pre><code>public class MainActivity extends Activity 
{

public ArrayList &lt;String&gt; choices = new ArrayList &lt;String&gt;();
public ListView listView = (ListView) findViewById(R.id.listView1);
public String [] choicesArray;


@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ListView listView = (ListView) findViewById(R.id.listView1);
    choicesArray = new String [] {"You have not entered a choice yet"};
    ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
            android.R.layout.simple_list_item_1, android.R.id.text1, choicesArray);
    listView.setAdapter(adapter);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) 
{
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

//adds the string to the list
public void addString(View view) 
{

    choicesArray = (String[]) choices.toArray();
    EditText editText = (EditText) findViewById(R.id.edit_choice);
    String message = editText.getText().toString();
    choices.add(message);

}


}
</code></pre>

<p>Hopefully this makes sense and thank you for any help. </p>
