getIntent and ArrayList



我在第一个活动ArrayList<ListeJoueurs> la = new ArrayList<>();中有一个ArrayList,定义如下。我想把这个ArrayList放到另一个活动中。我没有找到一个简单的解决方案与getIntent()我能做些什么呢?非常感谢你的帮助。

public class ListeJoueurs {
String  Nom;
String  Prenom;
Long  Licence;
String  Cat;
String Select;
String dteN;
int imageClick;
// Constructor
public ListeJoueurs(String Nom, String Prenom, Long Licence, String Cat, String Select, String dteN, int imageClick)
{
this.Nom = Nom;
this.Prenom = Prenom;
this.Licence = Licence;
this.Cat = Cat;
this.Select = Select;
this.dteN = dteN;
this.imageClick = imageClick;
}
// Used to print student details in main()
public String toString()
{
return  this.Nom  + " " + this.Prenom + " " + this.Licence + " " + this.Cat + " " + this.Select + " " + this.dteN  + " " + this.imageClick;
}
}

您可以使用Gson库在activity之间传输数据。您可以将数据列表转换为JSON并传递它。这些链接可以帮助你。

https://stackoverflow.com/a/19700319/12980812

https://medium.com/@theblackcat102 passing-object-between-activity-using-gson-7dfa11d74e06

最新更新