의도를 통해 객체의 ArrayList를 전달하려고 시도하지만 작동하지 않습니다. 여기에 내가 무엇을 가지고 :인 텐트를 통해 객체의 ArrayList 전달 - Java (Android)
public class QuestionView extends Activity {
//variables and other methods...
public void endQuiz() {
Intent intent = new Intent(QuestionView.this, Results.class);
intent.putExtra("correctAnswers", correctAnswers);
intent.putExtra("wrongAnswers", wrongAnswers);
intent.putParcelableArrayListExtra("queries", queries);
startActivity(intent);
}
}
텐트는 여기에 수신됩니다
public class Results extends Activity {
int cAnswers;
int wAnswers;
ArrayList<Question> qs;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.resultsmain);
cAnswers = getIntent().getIntExtra("correctAnswers", -1);
wAnswers = getIntent().getIntExtra("wrongAnswers", -1);
qs = getIntent().getParcelableArrayListExtra("queries");
//more code...
}
}
두의 int는 correctAnswer 및 wrongAnswers가 수신되고 있으며, 내가 그들을 사용할 수 있습니다. ArrrayList가 나오지 않습니다. endQuiz() 메소드에는 오류가 없지만 'qs = getIntent(). getParcelableArrayListExtra ("queries");' 오류가 발생하고 "Bound Mismatch"라고 말하고 있습니다.
이 문제에 대한 도움이 필요하십니까?
질문 클래스 :
public class Question {
String a1;
String a2;
String a3;
String a4;
int correctAnswer;
String query;
int selectedAnswer;
boolean correctness;
public Question() {
}
public Question(String a1, String a2, String a3, String a4, int correctAnswer, String query, int selectedAnswer, boolean correctness) {
this.a1 = a1;
this.a2 = a2;
this.a3 = a3;
this.a4 = a4;
this.correctAnswer = correctAnswer;
this.query = query;
this.selectedAnswer = selectedAnswer;
this.correctness = correctness;
}
}
'Question' 클래스는 [Parcelable] (http://developer.android.com/reference/android/os/Parcelable.html)을 구현합니까? – wsanville
아니요 ... 왜 그가 그것을 캐스팅하는지 ... (ArrayList extends Parcelable>) queries :':) 확실히 도움이되지 않습니다 – Selvin
ArrayList가 실제로 보이는 쿼리 유형을 확인할 수 있습니까? 나는 클래스를 의미합니다 ... – LuxuryMode