6

I want to create an application based on quiz which consists of 14 questions.

Can anyone tell me how do I need to go from one question to another by clicking on next button.If I use an Intent then I am afraid that I will be creating 14 Activities :(

I don't think that is the programmatic procedure too.

6 Answers 6

3

You can stay in the same Activity and keep track of the question.

You might want to use a TextSwitcher to add a fade in/fade out animation when swapping the question's text.

3

You could have the button click just update the questions text to be the next question.

     nextButton.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
             questionTextView.setText(questionTwo);

         }
     });
2

@Vivek you can use view flipper

this might help you

http://www.bogotobogo.com/Android/android9TabWidgetFlipper.html#SlidingDrawer

http://www.warriorpoint.com/blog/2009/05/29/android-switching-screens-by-dragging-over-the-touch-screen/

1

Change the text of your textviews where the questions are.

@Override
protected void onCreate(Bundle savedInstanceState) {
     Button nextButton = (Button) findViewById(R.id.yourButtonId);
     TextView questionTextView = (TextView) findViewById(R.id.yourTextViewId);

     nextButton.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
             questionTextView.setText("Your Next Question");

         }
     });
}
1

A Fragment is a piece of an application's user interface or behavior that can be placed in an Activity.

  1. Has its own lifecycle;
  2. Receives its own input events;
  3. Can be added or removed while the activity is running;

Believe me that is the best method. I have been introduced to fragments having an application with quotes. The list of the quotes in left and the quotes that were changing on left when an author have been selected.

0

I'm using android.widget.ViewFlipper that contains views where one view contains TextView (question) and "input control" for answer (selectboxes, date/time widget, radiogroup, etc).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.