Android Making Quiz App with Database

2019-05-27 05:43发布

问题:

Hello guys I want to make a Quiz Application but I have some problems and I don't know how to do them, I am new in Android and I thought that you can help me on it.

I have a database with "Questions" table and "Answers" table.

Database is like a picture, there are more than 500 questions also every question has 2 or 3 or 4 answers which only one is true.

So I want to do when user starts the quiz, he gets randomly 30 questions from the database and gets RadioButtons as answer number of that question.

For example 1st question has 3 answers, he will have these 3 answers as radio buttons, 2nd question has 2 answers, he will have these 2 answers as radio buttons.

回答1:

It's just basic Android programming.

Just search for some tutorials how to use random functions and sql.

  1. Make a sqlite database in your android app (http://www.vogella.com/tutorials/AndroidSQLite/article.html)
  2. Make a layout with a question and radio buttons etc.
  3. Make a fragmentstatepager activity with the layout in one fragment.
  4. Initialize fragmentstatapger with all questions count (5000 or something)
  5. Make a dynamic fragment with the quiz layout, get a question randomly loaded (http://developer.android.com/reference/java/util/Random.html)

  6. the dynamic fragment layout can be based on this url For a Quiz app see this url (http://code.tutsplus.com/tutorials/android-ui-workshop-build-an-interactive-quiz-app--mobile-14208)

  7. Don't forget to add a row to your table with a check if the user whether had this question before.

You only need to change the onclicks in something which checks if the answer is right in the database etc.

Remember it'll be hard to make it all work if you make an app like this for the first time. But just keep going.