so I am implementing a test app in which I will create a Tournament object as Parcelable and will pass them between intents. A tournament include: . A tournament name . Rule . Rule for matching players (random/manual) . An array list of Players
This is what I have so far:
Tournament.java
public class TournamentData implements Parcelable {
private String tourName;
private int bestOf;
private boolean isRandom;
private ArrayList<Player> playerList;
public TournamentData(String name, int tourBestOf, boolean random) {
this.tourName = name;
this.bestOf = tourBestOf;
this.isRandom = random;
}
public void addPlayer(Player newPlayer) {
this.playerList.add(newPlayer);
}
public ArrayList<Player> getPlayerList() {
return playerList;
}
/* getters and setters excluded from code here */
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}
public void writeToParcel(Parcel out, int flags) {
// TODO Auto-generated method stub
}
Player.java
public class Player {
private String playerName;
private String playerEmail;
public Player(String name, String email) {
this.playerName = name;
this.playerEmail = email;
}
/* getter and setters are excluded */
}
I am new to Android (i mean very very new; 10 hours into it I guess). So I am wondering: . Is it possible to create a Parcelable object given the specs of Tournament object that has ArrayList? . How to store all the tournament data into a Parcelable object and access them from the other activity? (namely A and B).