Reputation: 3
I have a few activities where each one is a question and a last activity which will show the score to user. How do I do this? Can anyone teach me or give some example to use as reference?
How can I store the score for each question and then show the total score in the last activity? I don't know how to write the code for this. Can anyone teach me?
Upvotes: 0
Views: 93
Reputation: 1971
You can declare any global varibale and increment it for all the correct answers.
When your quiz finished you can pass that varibale to the new activty that will show the result..
for ex--
int score; QuizActivity.java
Intent it = new Intent(QuizActivity.this, AnswersActivity.class);
it.putIntExtra("Score",score);
StartActivity(it);
AnswersActivty.java
Intent it = getIntent();
int score = it.getIntExtra("Score");
I hope this will help you...
Upvotes: 1