I'm a little lost here. I'm trying to add a custom object(with 3 integers, 1 double, and 1 date) to an arraylist when a button is clicked. I want the arraylist to be shown in another classes listview. So far this is what I have for the custom class:
ublic class Record {
private Integer squat, bench, dead;
private double total;
private Date dateTime;
public Record(int squat, int bench, int dead, double total, Date date) {
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;
}
}
EDIT: Classname: MyMaxes.class : In the class where the button is clicked, I have this(I'm not sure how to get the current date when button is clicked):
public ArrayList<Record> records = new ArrayList<>();
maxTotal = maxDead + maxBench + maxSquat;
int maxDead = Integer.parseInt(mEditTextDead.getText().toString());
int maxSquat = Integer.parseInt(mEditTextSquat.getText().toString());
int maxBench = Integer.parseInt(mEditTextBench.getText().toString());
records.add(new Record(maxSquat, maxBench, maxDead, maxTotal, ));
Edit: Class name = MyProgress.class : And in the class I want to set the listview to this arraylist(I'm not sure how to get the arraylist from the other class):
RecordAdapter adapter = new RecordAdapter(getApplicationContext(),R.layout.custom_record);
ListView listViewRec = (ListView) findViewById(R.id.listViewRecord);
}
This is my RecordAdapter class, but im not sure what to add there either:
public class RecordAdapter extends ArrayAdapter<Record> {
public RecordAdapter(Context context, int resource) {
super(context, resource);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return super.getView(position, convertView, parent);
}
}
Thanks for any help