0

For a school project a need to build a android quiz application with multiple question types. These question types are: Multiple Choice, Textbox, Radio button and a minigame in which you need to sort images in the right order in a draggable gridview.

I think to use multiple activities for this isn't needed and that i just can switch the overall layout between multiple xml layout files for each of these question types if i first check what the type of the question is. Most other posts on stackoverflow are only related to quizzes with one type of question, without minigames in between the questions so i wanted to know what the best method is to switch between these different question types and layouts. At least i know i need a switch/case to check the different question types (for my prototype located in a array) and switch to right type if you press the "Next question" Button that is located under the answers (under the gridview in case of the minigame).

I already searched on the internet for it and i found the following options but i don't know what's best in my case. I also wanted to make the app compatible with android version 2.3.3. Some examples could also help me very much!!

  • (Adapter)Viewflipper
  • An Adapter that changes a inner layout
  • setContentView() of the main activity
  • Including a layout in another layout and change it
  • Make some views/layouts visible and invisible.
  • Make a new activity for each question (if there is no other option)

2 Answers2

1

You can do it with a ViewFlipper. In the ViewFlipper XML, just list each layout for each question type and just have the user scroll through the flipper to get to the type they want. You can probably do this by setting a OnTouchListener and calling showNext() as they scroll.

Setting the correct data for each view is solely up to you; you would just have to match the correct data based on what view they are in to populate it correctly. That's it :)

CompEng88
  • 1,336
  • 14
  • 25
0

It depends on how you want to structure your quizes are the questions supposed to be mixed together? Are they all seperate quizes.

If they are separate the easiest approach would probably to implement a view pager. With the view pager it will create a new fragment for each page. From here you have a two options, you can either create a new fragment for each quiz type. Or you can create one quiz fragment and pass an argument to that fragment to select the correct layout. Either way you'll likely want a new layout for each quiz type. As for your minigame you can just include that as a page in your view pager in between two quiz views.

All of the above will work on 2.3 and above if you use the support library. I would recommend checking out some tutorials on viewPager they are fairly straightforward to use.

Ben
  • 1,285
  • 1
  • 9
  • 15
  • It's only one quiz with multiple questions/answers and the gridview minigame. All the different mentioned question types and the minigame are mixed together in one quiz. I going to try the Viewpager option. – The Fettuck Mar 07 '14 at 15:05