相关疑难解决方法(0)

使用ArrayList <Object>进行Android Parcelable实现

所以我正在实现一个测试应用程序,在其中我将创建一个Tournament对象作为Parcelable并将在意图之间传递它们.比赛包括:.锦标赛名称.规则 .匹配玩家的规则(随机/手动).玩家阵列列表

这是我到目前为止:

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 …
Run Code Online (Sandbox Code Playgroud)

android arraylist parcelable android-activity

7
推荐指数
1
解决办法
2万
查看次数

如何在android中写入和读取ArrayList <String>到parcel

在我的项目中,我必须编写和读取ArrayList<String>包,我尝试使用writeList和writeStringList但没有用,我在阅读列表时遇到异常.

有谁可以帮助我吗?

提前致谢.

android

6
推荐指数
1
解决办法
6826
查看次数

Android Parcelable对象返回Null

我有Product class.我想将产品对象的一个​​活动传递给另一个.

我这样实现了:

 public class Product implements Parcelable{
     private double availableQuantity;
     private double price;
     private String productCode;    
     private String description;
     private String nonStockItemFlag;   
     private String activeFlag;
     private String kitProductFlag;
     private double value;
     private ArrayList<Product> product;
     private double qty;

    public Product() {

}


/**
 * @param availableQuantity
 * @param price
 * @param productCode
 * @param description
 * @param nonStockItemFlag
 * @param kitProductFlag
 * @param qty
 * @param grossValue
 * @param value
 */

public Product(double availableQuantity, double price, String productCode,
        String description, …
Run Code Online (Sandbox Code Playgroud)

android

3
推荐指数
1
解决办法
7094
查看次数

标签 统计

android ×3

android-activity ×1

arraylist ×1

parcelable ×1