Android制作带有数据库的测验应用 [英] Android Making Quiz App with Database

查看:70
本文介绍了Android制作带有数据库的测验应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我想做一个测验应用程序,但是我遇到了一些问题,我不知道该怎么做,我是Android的新手,我想您可以在上面帮忙.

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.

数据库就像一张图片,有500多个问题,每个问题有2或3或4个答案,只有一个是正确的.

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.

所以我想在用户开始测验时做,他从数据库中随机获得30个问题,并获得RadioButtons作为该问题的答案编号.

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.

例如第一个问题有3个答案,他将把这3个答案作为单选按钮,第二个问题有2个答案,他将把这2个答案作为单选按钮.

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.

推荐答案

这只是基本的Android编程.

It's just basic Android programming.

只需搜索一些有关如何使用随机函数和sql的教程即可.

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

  1. 在您的android应用中创建一个sqlite数据库 ( http://www.vogella.com/tutorials/AndroidSQLite/article.html)
  2. 使用问题和单选按钮等进行布局.
  3. 进行一个fragmentstatepager活动,将布局放在一个片段中.
  4. 初始化带有所有问题计数(5000左右)的fragmentstatapger
  5. 使用测验布局制作动态片段,随机加载一个问题(

  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)

动态片段布局可以基于此url 对于测验应用,请参见以下网址(

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)

请不要忘记在表中添加一行,并检查用户之前是否有这个问题.

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

您只需要更改onclicks即可检查答案在数据库中是否正确等等.

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.

这篇关于Android制作带有数据库的测验应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆