I'm looking to create a simple pc shop ticket system. I have a new ticket activity, a list ticket activity, and an edit ticket activity. The application begins by launching the new ticket activity as shown below
To pass data between the new ticket activity and the list ticket activity I have a simple ticket object that implements parcelable as shown here:
import android.icu.text.SimpleDateFormat;
import android.os.Parcel;
import android.os.Parcelable;
import java.text.ParseException;
import java.util.Date;
public class Ticket implements Parcelable {
private int ticket_id;
private String name, creation_date, problem, status, fix_date;
public Ticket(){}
public Ticket(int ticket_id, String name, String creation_date, String problem, String status, String fix_date){
this.ticket_id = ticket_id;
this.name = name;
this.creation_date = creation_date;
this.problem = problem;
this.status = status;
this.fix_date = fix_date;
}
protected Ticket(Parcel in) {
this.ticket_id = in.readInt();
this.name = in.readString();
this.creation_date = in.readString();
this.problem = in.readString();
this.status = in.readString();
this.fix_date = in.readString();
}
public static final Creator<Ticket> CREATOR = new Creator<Ticket>() {
@Override
public Ticket createFromParcel(Parcel in) {
return new Ticket(in);
}
@Override
public Ticket[] newArray(int size) {
return new Ticket[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(ticket_id);
dest.writeString(name);
dest.writeString(creation_date);
dest.writeString(problem);
dest.writeString(status);
dest.writeString(fix_date);
}
public String ticketToString(){
String temp = "";
temp = "Ticket ID: " + ticket_id + "\nCustomer Name: " + name + "\nDate Created: " + creation_date + "\nProblem: " + problem +
"\nStatus: " + status + "\nFix Date:" + fix_date;
return temp;
}
public int getTicketId() {
return ticket_id;
}
public void setTicketId(int ticket_id) {
this.ticket_id = ticket_id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCreationDate() {
return creation_date;
}
public void setCreationDate(String creation_date) {
this.creation_date = creation_date;
}
public String getProblem() {
return problem;
}
public void setProblem(String problem) {
this.problem = problem;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getFixDate() {
return fix_date;
}
public void setFixDate(String fix_date) {
this.fix_date = fix_date;
}
}
My list ticket that this ticket is passed to is simply going to be a scrollable list of tickets (fragments) that I can highlight and choose to edit or delete. My question is here: I know I have to create an array list of tickets to add or delete dynamically, however how do I update and create a dynamic list of fragments, while passing data from each object in our array list of tickets? I am just coming up short trying to wrap my head around a way to complete this.