title: ANDROID/JAVA Newbie having problems with classes in separate files
body: <p>I have create a very simple app which shows a <code>ListView</code> which in turn shows the contents of a <code>ListArray</code>. I have also added a button which when clicked, adds another item to the <code>ListView</code>.
  Now here's the problem:
  After reading other people's code I have noticed their <code>MainActivity</code> file tends to be the default file and all their classes and created in separate files. I am trying to put my <code>ArrayAdapter</code>, <code>Button</code> and <code>ListArray</code> code into a separate file.. just to make it all look nicer!
  Does anyone have any ideas as to why when I run my app (it compiles fine/ no errors) My <code>ListView</code> no longer populates or adds an item on the button click.
  Thanks for your time! Here's my code:</p>
  
  <p><em><strong>MainActivity.Java</em></strong></p>
  
  <pre><code>package com.example.shoppingapp;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.Menu;
  
  
  public class MainActivity extends Activity {
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);                                      
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  }
  </code></pre>
  
  <p><em><strong>ArrayAdapterClass</em></strong></p>
  
  <pre><code>package com.example.shoppingapp;
  
  import java.util.ArrayList;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.ListView;
  
  public class ArrayAdapterClass extends Activity {
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      final ArrayList&lt;String&gt; myStringArray = new ArrayList&lt;String&gt;();
      myStringArray.add("One");
  
      final ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
           android.R.layout.simple_list_item_multiple_choice, myStringArray);
  
      ListView listView = (ListView) findViewById(R.id.listview);
      listView.setAdapter(adapter);
  
      final Button button = (Button) findViewById(R.id.addnote);
  
      button.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
               // Perform action on click
               // Toast textPopup = Toast.makeText(getApplicationContext(), "Hello",     Toast.LENGTH_SHORT);
               // textPopup.show();
                  myStringArray.add("Two");
                  adapter.notifyDataSetChanged();  
                  }
               });    
  }
  }
  </code></pre>
  
  <p>edit: I should also add... When all of the code is in a single file (the MainActivity one) it all runs fine.</p>