title: Arraylist populating Listview in separate class not working
body: <p>I'm trying to add an item to arraylist/adapter on a Button click in my class </p>
  
  <p>MyMaxes.java:</p>
  
  <pre><code>Date currentDate = new Date();
  ArrayAdapter&lt;Record&gt; records = new ArrayAdapter&lt;Record&gt;(getApplicationContext(), R.layout.custom_record);
  records.add(new Record(currentDate ,maxSquat, maxBench, maxDead, maxTotal));
  records.notifyDataSetChanged();
  </code></pre>
  
  <p>And in my other class, MyProgress.java, I'm trying to assign that adapter to the ListView:</p>
  
  <pre><code>ListView listViewRec = (ListView) findViewById(R.id.listViewRecord);
  listViewRec.setAdapter(records);
  </code></pre>
  
  <p>The records is underlined and says "Expression Expected".<br>
  I feel I need to set the TextViews in my custom layout file in the adapter somehow so it knows which item to put in which TextView.<br>
  Am I supposed to have an adapter class? </p>
  
  <p>here is my custom_record:</p>
  
  <pre><code> &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Date"
          android:textSize="18sp"
          android:id="@+id/txtDate"
          android:layout_alignParentTop="true"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"/&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Bench"
          android:id="@+id/txtBench"
          android:paddingRight="5dp"
          android:textSize="18sp"
          android:layout_gravity="center_horizontal"
          android:layout_alignParentTop="true"
          android:paddingLeft="5dp"
          android:layout_toLeftOf="@+id/txtSquat"
          android:layout_toStartOf="@+id/txtSquat"/&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Squat"
          android:textSize="18sp"
          android:paddingRight="5dp"
          android:id="@+id/txtSquat"
          android:layout_alignParentTop="true"
          android:paddingLeft="5dp"
          android:layout_toLeftOf="@+id/txtDead"
          android:layout_toStartOf="@+id/txtDead"
          /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Dead"
          android:paddingRight="5dp"
          android:textSize="18sp"
          android:id="@+id/txtDead"
          android:layout_alignParentTop="true"
          android:paddingLeft="5dp"
          android:layout_toLeftOf="@+id/txtTotal"
          android:layout_toStartOf="@+id/txtTotal"/&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Total"
          android:textSize="18sp"
          android:paddingRight="5dp"
          android:paddingLeft="5dp"
          android:id="@+id/txtTotal"
          android:layout_marginRight="34dp"
          android:layout_marginEnd="34dp"
  
          android:layout_alignParentRight="true"
          android:layout_alignParentEnd="true"/&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>and my custom object:</p>
  
  <pre><code>public class Record {
  
      private Integer squat, bench, dead;
      private double total;
      private Date dateTime;
  
      public Record(Date date,int squat, int bench, int dead, double total) {
          this.bench = bench;
          this.dateTime = date;
          this.dead = dead;
          this.squat = squat;
          this.total = total;
      }
  
      public Integer getSquat() {
          return squat;
      }
  
      public void setSquat(Integer squat) {
          this.squat = squat;
      }
  
      public Integer getBench() {
          return bench;
      }
  
      public void setBench(Integer bench) {
          this.bench = bench;
      }
  
      public Integer getDead() {
          return dead;
      }
  
      public void setDead(Integer dead) {
          this.dead = dead;
      }
  
      public Double getTotal() {
          return total;
      }
  
      public void setTotal(Integer total) {
          this.total = total;
      }
  
      public Date getDateTime() {
          return dateTime;
      }
  
      public void setDateTime(Date dateTime) {
          this.dateTime = dateTime;
      }
  }
  </code></pre>
  
  <p>Edit ::Verify example::</p>
  
  <p>main activity code:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      Button mButton;
      Integer maxSquat = 1;
      Integer maxBench = 1;
      Integer maxDead = 1;
      Double maxTotal = 3.0;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          mButton= (Button) findViewById(R.id.btnTest);
          mButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Date currentDate = new Date();
                  ArrayAdapter&lt;Record&gt; records = new ArrayAdapter&lt;Record&gt;(getApplicationContext(), R.layout.custom_record);
                  records.add(new Record(currentDate ,maxSquat, maxBench, maxDead, maxTotal));
                  records.notifyDataSetChanged();
              }
          });
      }
  }
  </code></pre>
  
  <p>listview.java: </p>
  
  <pre><code>public class listview extends MainActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.listview);
  
          ListView listViewRec = (ListView) findViewById(R.id.listViewRecord);
          listViewRec.setAdapter(records);
      }
  }
  </code></pre>
  
  <p>listview.xml:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"&gt;
  
  &lt;ListView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:id="@+id/listViewRecord"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>activitymain.xml:</p>
  
  <pre><code>&lt;RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context="com.bestworkouts.myapplication.MainActivity"&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Hello World!"/&gt;
  
  &lt;Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/btnTest"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>I then have the record.java class from above, as well as the custom_record.xml from above.<br>
  Oddly enough, this one gives me a different error, it cannot resolve "records" when setting the adapter, where in my app it says "Expression Expected" for records.</p>