2

アプリ内で基本的なプロファイルを作成する次のコードがあります。これには、ユーザーのすべてのパフォーマンス データを配列およびその他のさまざまなプリミティブ データ型で保持する別のクラスのオブジェクトが含まれています。ユーザー プロファイル オブジェクトをアプリ内のさまざまなアクティビティに渡して読み取りまたは書き込みできるようにするには、このクラス内にパーセル可能なインターフェイスをどのように実装すればよいでしょうか? この Profile クラスだけでなく Performance クラス内にも parcelable インターフェースを実装する必要がありますか?

public class Profile {

private String name;
private String email;
private Performance Progress;

private int seed;
private int LastRevisionQuestion = 0;

private int[] LastQuestionQuizLinear = {0,0,0};
private int[] tempScoreQuizLinear = {0,0,0};

private int[] LastQuestionQuizRandom = {0,0,0};
private int[] tempScoreQuizRandom = {0,0,0};

private int[] LastQuestionTimedQuizLinear = {0,0,0};
private int[] tempScoreTimedQuizLinear = {0,0,0};
private int[] tempTotalTimeTimedQuizLinear = {0,0,0};

private int[] LastQuestionTimedQuizRandom = {0,0,0};
private int[] tempScoreTimedQuizRandom = {0,0,0};
private int[] tempTotalTimeTimedQuizRandom = {0,0,0};


/**
 * Default constructor
 */
public Profile(){
    this("ProfileName", "ProfileEmail");
}

/**
 * Overloaded constructor takes user name and email address as input parameter to create a new user
 * @param name
 * @param email
 */
public Profile(String name, String email){
    this.name = name;
    this.email = email;
    setProgress(new Performance());
}
}
4

1 に答える 1

1

単純なデータ型 (int、String、boolean など)、parcelables、およびmaps のみをパーセルできます。そうです、あなたの最善の策は、同様に実装parcelableすることです。Performance

于 2011-12-08T22:25:53.517 に答える